Forums / Developer / PearDB inside extension/module

PearDB inside extension/module

Author Message

Dan C

Thursday 16 December 2004 12:23:51 pm

Hi,

I'm trying to use a pear DB instance inside of an extension/module. I'm storing the $db instance inside $GLOBALS['mydbinst'] and its working perfectly except for one thing:

I'm connecting to database 'dbOne' with PearDB and ezpublish is using the 'ezpub' database. When I enable debugging, I can see that ezpub is now trying to access ez tables from 'dbOne' instead of the 'ezpub' table and its causing some problems(Namely the menu template doesn't show up anymore, it can't grab any content from the db).

Does anyone know why this is happening or know of any workarounds?

Thanks,

Dan

Dan C

Thursday 16 December 2004 6:26:53 pm

For anyone else experience similar problems... I haven't found out what the problem is, but I have a solution.

I'm thinking perhaps the problem is related to ezDb not using mysql_select_db properly or something... but it doesn't entirely make sense because pearDB and ezDb should be using different link id's... so I wasn't able to figure it out with my testing. I tried using global variables, local variables inside functions, static variables inside classes... and it was always the same problem.

Here's my solution:

I get peardb to connect to the 'ezpub' database, and every SQL query I do needs to be in the form of 'SELECT * FROM otherdb.tablename' -- in other words, I just specify the name of the other DB I want to access and this seems to keep ezDb happy and inside the correct database.

Dan

eZ debug

Timing: Jan 18 2025 10:58:34
Script start
Timing: Jan 18 2025 10:58:34
Module start 'content'
Timing: Jan 18 2025 10:58:34
Module end 'content'
Timing: Jan 18 2025 10:58:34
Script end

Main resources:

Total runtime0.7360 sec
Peak memory usage4,096.0000 KB
Database Queries53

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0084 588.8281180.8359
Module start 'content' 0.00840.7202 769.6641428.8906
Module end 'content' 0.72870.0072 1,198.554742.1094
Script end 0.7359  1,240.6641 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.4223140.0002
Check MTime0.00130.1825140.0001
Mysql Total
Database connection0.00070.098610.0007
Mysqli_queries0.694494.3480530.0131
Looping result0.00050.0706510.0000
Template Total0.701995.420.3509
Template load0.00200.274020.0010
Template processing0.699995.093420.3499
Template load and register function0.00030.045510.0003
states
state_id_array0.00140.186310.0014
state_identifier_array0.00100.137320.0005
Override
Cache load0.00160.2160150.0001
Sytem overhead
Fetch class attribute can translate value0.00070.089810.0007
Fetch class attribute name0.00140.188520.0007
XML
Image XML parsing0.00010.014810.0001
class_abstraction
Instantiating content class attribute0.00010.014720.0001
General
dbfile0.00450.6111120.0004
String conversion0.00000.000830.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
2content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 6
 Number of unique templates used: 4

Time used to render debug report: 0.0001 secs