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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 00:35:08
Script start
Timing: Jan 31 2025 00:35:08
Module start 'layout'
Timing: Jan 31 2025 00:35:08
Module start 'content'
Timing: Jan 31 2025 00:35:09
Module end 'content'
Timing: Jan 31 2025 00:35:09
Script end

Main resources:

Total runtime0.9934 sec
Peak memory usage8,192.0000 KB
Database Queries52

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0047 588.1328151.2109
Module start 'layout' 0.00470.0037 739.3438220.6875
Module start 'content' 0.00840.9840 960.03134,162.6719
Module end 'content' 0.99240.0009 5,122.70317.8516
Script end 0.9933  5,130.5547 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.3447160.0002
Check MTime0.00120.1248160.0001
Mysql Total
Database connection0.00070.069410.0007
Mysqli_queries0.920092.6134520.0177
Looping result0.00060.0555500.0000
Template Total0.944795.120.4724
Template load0.00190.189520.0009
Template processing0.942894.915220.4714
Template load and register function0.00120.116310.0012
states
state_id_array0.00140.136610.0014
state_identifier_array0.00190.188520.0009
Override
Cache load0.00150.1548150.0001
Sytem overhead
Fetch class attribute can translate value0.00190.189310.0019
Fetch class attribute name0.00290.295020.0015
XML
Image XML parsing0.00010.013110.0001
class_abstraction
Instantiating content class attribute0.00000.001020.0000
General
dbfile0.00070.0688100.0001
String conversion0.00000.000840.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
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_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