Multiple database connections in stensi's Datamapper

#1
[eluser]FabricioFirmino[/eluser]
Hi everybody.


I'm using Stensi's datamapper and now i need connect in two distincts databases, so, i've configured my database.php like bellow:

Code:
$db['default']['hostname'] = "localhost";
$db['default']['username'] = "user";
$db['default']['password'] = "password";
$db['default']['database'] = 'databalse';
$db['default']['dbdriver'] = "mysql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";


$db['first']['hostname'] = "localhost";
$db['first']['username'] = "first_user";
$db['first']['password'] = "first_password";
$db['first']['database'] = 'first_databalse';
$db['first']['dbdriver'] = "mysql";
$db['first']['dbprefix'] = "";
$db['first']['pconnect'] = TRUE;
$db['first']['db_debug'] = TRUE;
$db['first']['cache_on'] = FALSE;
$db['first']['cachedir'] = "";
$db['first']['char_set'] = "utf8";
$db['first']['dbcollat'] = "utf8_general_ci";


$db['second']['hostname'] = "localhost";
$db['second']['username'] = "second_user";
$db['second']['password'] = "second_password";
$db['second']['database'] = 'second_databalse';
$db['second']['dbdriver'] = "mysql";
$db['second']['dbprefix'] = "";
$db['second']['pconnect'] = TRUE;
$db['second']['db_debug'] = TRUE;
$db['second']['cache_on'] = FALSE;
$db['second']['cachedir'] = "";
$db['second']['char_set'] = "utf8";
$db['second']['dbcollat'] = "utf8_general_ci";


My Model classes are like bellow:

Code:
<?php

class Sample extends DataMapper
{
    
    public $table = 'samples';

    function Sample()
    {
        
        parent::DataMapper();
    }
}

?>



How can i set which database (default, first or second) this model is mapped?


[]s


Messages In This Thread
Multiple database connections in stensi's Datamapper - by El Forum - 01-17-2011, 11:53 AM
Multiple database connections in stensi's Datamapper - by El Forum - 01-17-2011, 01:39 PM
Multiple database connections in stensi's Datamapper - by El Forum - 01-17-2011, 04:38 PM
Multiple database connections in stensi's Datamapper - by El Forum - 01-17-2011, 05:24 PM
Multiple database connections in stensi's Datamapper - by El Forum - 01-18-2011, 04:07 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.