Welcome Guest, Not a member yet? Register   Sign In
Multiple databases and db_params with Datamapper
#1

[eluser]Kh3ops[/eluser]
Hello everyone,

After browsing the forum for some time, I can't find the answer to my issue.

I'm using Datamapper ORM (1.8.2) and trying to make a specific model connect to another database :

Code:
<?php
class Zone extends DataMapper {


/**
  * override the database connections with this option
  */

var $db_params = 'dns';
  
    public function __construct()
    {
        // model constructor
        parent::__construct();
    }
}
?>

According to documentation, this is supposed to make model connect the the dabase described as "dns" in config/database.php.

Code:
// Secondary database
$db['dns']['hostname'] = '*****';
$db['dns']['username'] = '*****';
$db['dns']['password'] = '*****';
$db['dns']['database'] = '*****';
$db['dns']['dbdriver'] = 'mysql';
$db['dns']['dbprefix'] = '';
$db['dns']['pconnect'] = FALSE;
$db['dns']['db_debug'] = TRUE;
$db['dns']['cache_on'] = FALSE;
$db['dns']['cachedir'] = '';
$db['dns']['char_set'] = 'utf8';
$db['dns']['dbcollat'] = 'utf8_general_ci';
$db['dns']['swap_pre'] = '';
$db['dns']['autoinit'] = TRUE;
$db['dns']['stricton'] = FALSE;

Except it doesn't...

When displaying object details in controller :

Code:
$zone = new zone();

I get a MySQL error showing the default database and not the database specified in "dns" configuration.

Code debug shows that db_params is not set on my object despite my declaration.

Quote:Zone Object ( [db_params] => [error] => [stored] => [prefix] => [join_prefix] => [table] => zones [model] => zone [primary_key] => id [error_prefix] =>

Any idea?

Thanks,


Messages In This Thread
Multiple databases and db_params with Datamapper - by El Forum - 08-25-2012, 11:43 AM
Multiple databases and db_params with Datamapper - by El Forum - 08-29-2012, 01:45 AM
Multiple databases and db_params with Datamapper - by El Forum - 08-29-2012, 01:49 AM
Multiple databases and db_params with Datamapper - by El Forum - 08-29-2012, 01:52 AM
Multiple databases and db_params with Datamapper - by El Forum - 08-29-2012, 06:31 AM
Multiple databases and db_params with Datamapper - by El Forum - 11-16-2012, 11:38 AM
Multiple databases and db_params with Datamapper - by El Forum - 11-16-2012, 04:06 PM



Theme © iAndrew 2016 - Forum software by © MyBB