Re: db_dataobject and multiple databases

From: Date: Wed, 18 Oct 2006 19:53:57 +0000
Subject: Re: db_dataobject and multiple databases
References: 1 2 3 4  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-25537@lists.php.net to get a copy of this message
The trouble is that 2 or more of the databases have a table with the same name. This means I can only create an object DO_Dummytable from one of the databases while the other databases Dummytable does not have a DO generated for it. The documentation looks like there is a table_ prefix that can be used to overcome this but I cant seem to make sense of the example. On 10/18/06, Ian Warner <iwarner@triangle-solutions.com> wrote:
Matthew Deir wrote: HI Ian, Thanks for the quick reply. I'm using an array: $do_options = &PEAR::getStaticProperty('DB_DataObject','options'); $do_options = array(
//    'database'    => 'mysql://apache:apache@localhost /mysql',
   'database_adv_star'    => 'mysql://apache:apache@localhost/adv_star',
   'database_adv_massmail'    => 'mysql://apache:apache@localhost
/adv_massmail',
   'database_adv_mailtracking'    => ' mysql://apache:apache@localhost
/adv_mailtracking',
   'database_adv_reports'    => 'mysql://apache:apache@localhost
/adv_reports',
   'database_adv_ats'    => 'mysql://apache:apache@localhost/adv_ats',
'schema_location' => $GLOBALS['framework']['root']."/system/dataobjects", 'class_location' => $GLOBALS['framework']['root']."/system/dataobjects", 'require_prefix' => 'dataobjects/',
   'class_prefix'     => 'DO_'
); And the errors are ? Turn debugging to 5 If I remember correctly using a database name with an underscore _ in caused issues with the parser for using multi databases ? Try renaming a couple to eliminate this i.e.
   'database_advstar'    => 'mysql://apache:apache@localhost/adv_star',
   'database_advmassmail'    => 'mysql://apache:apache@localhost ,
On 10/18/06, Ian Warner <iwarner@triangle-solutions.com> wrote:
Matthew Deir wrote:
Hi, I'm having difficulty getting db_dataobject setup correctly with multiple databases that contain tables with the same name. I'm using createTables.php to generate the classes but of course only one file is created for the table that appears in several databases. Has anyone run into anything similar? Any guidance is appreciated.
Info is here 3/4s down
http://pear.php.net/manual/en/package.database.db-dataobject.intro-configuration.php
Please send some code of what you are doing now, are you using ini? Array? ie i think this is how you do it if i remember schema and all other stuff are in the one place hope that helps: // Create the array of options for DataObjects $config['DB_DataObject'] = array(
    'database_admin'         => 'mysqli://USER:PASS@localhost/admin',
    'database_other'         => 'mysqli://USER:PASS@localhost/other',
    'schema_location'  => ADMIN_DO . 'admin/schema',
    'class_location'   => ADMIN_DO . 'admin',
    'require_prefix'   => ADMIN_DO . 'admin',
    'class_prefix'     => 'DO_',
    'db_driver'        => 'MDB2',
    'extends_location' => ADMIN_DO . 'admin/Inter.php',
    'extends'          => 'DB_Inter');
$options = &PEAR::getStaticProperty('DB_DataObject', 'options'); $options = $config['DB_DataObject'];
Thanks, Matt.


« previous php.pear.general (#25537) next »