Re: DataObject Multiples Dbs
| From: | Alan Knowles | Date: | Fri, 23 Feb 2007 09:56:55 +0000 |
| Subject: | Re: DataObject Multiples Dbs | ||
| References: | 1 | Groups: | php.pear.general php.pear.general |
| Request: | Send a blank email to pear-general+get-26652@lists.php.net to get a copy of this message | ||
Have a look at _autoloadClass:
basically you could do something like this:
function MegaDataObject_factory($db, $table)
{
$opts = &PEAR::getStaticProperty("DB_DataObject",'options');
$mylocation = "/tmp/somwhere";
$opts['class_location'] = $mylocation . '/'. $table . '/';
$opts['class_prefix'] = "DataObjects_" . $db . "_";
return DB_DataObject::factory($table);
}
I'm sure there is an open feature request for something like that...
Regards
Alan
Ian Warner wrote:
> I basically have this below:
>
> Now as you can see sometimes I have a multiple DB situation if a package
> in my MVC FW requires to use it. I like to split the DB up as some
> packages have a large number of tables and contain then in one DB is too
> much.
>
> however the issues is that I would also like to keep the class location
> and schema location in seperate folders also.
>
> At the moment from the docs I see no indication on how to do that.
>
> do I - database_class_location do this? - tries and didn't work.
>
> any help appreciated on this
>
> require ST_INCLUDES . 'Data_Objects/Inter.php';
>
> $config['DB_DataObject'] =
> array(
> 'database_' . USE_DB => 'mysqli://user:pass@localhost/' .
> USE_DB,
> 'schema_location' => ST_DO . USE_DB,
> 'class_location' => ST_DO . USE_DB,
> 'require_prefix' => ST_DO . USE_DB,
> 'class_prefix' => 'DO_',
> 'db_driver' => 'MDB2',
> 'extends_location' => ST_DO . 'Inter.php',
> 'extends' => 'DB_Inter',
> 'quote_identifiers' => true,
> 'ignore_sequence_keys' => 'ALL'
> );
>
> // If a package is called for then include its constants here to set
> DB up.
> if (!empty($_GET['d']) && $_GET['d'] == 'packages') {
> require ST_PACKAGES . $_GET['p'] . DIRECTORY_SEPARATOR .
> 'constants.php';
> }
>
> if (defined('USE_PACKAGE_DB')) {
> $config['DB_DataObject'] += array('database_' . USE_PACKAGE_DB
> => 'mysqli://user:pass@localhost/' . USE_PACKAGE_DB);
> }
>
> $options =& PEAR::getStaticProperty('DB_DataObject', 'options');
> $options = $config['DB_DataObject'];