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.