Hello Dear I have another question, when trying to handle two connections to different databases, as I get to the right the model layer, for example:
database.php
$ active_group = ‘default’;
$ active_record = TRUE;
$ db [‘default’] [‘hostname’] = ‘localhost’;
$ db [‘default’] [‘username’] = ‘1 ‘;
$ db [‘default’] [‘password’] = ‘1 ‘;
$ db [‘default’] [‘database’] = ‘BD1’;
$ db [‘default’] [‘dbdriver’] = ‘mysql’;
$ db [‘default’] [‘dbprefix’] =’‘;
$ db [‘default’] [‘pconnect’] = FALSE;
$ 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 [‘default’] [‘swap_pre’] =’‘;
$ db [‘default’] [‘autoinit’] = TRUE;
$ db [‘default’] [‘stricton’] = FALSE;
$ db [‘db2’] [‘hostname’] = ‘localhost’;
$ db [‘db2’] [‘username’] = ‘2 ‘;
$ db [‘db2’] [‘password’] = ‘2 ‘;
$ db [‘db2’] [‘database’] = ‘BD2’;
$ db [‘db2’] [‘dbdriver’] = ‘mysql’;
$ db [‘db2’] [‘dbprefix’] =’‘;
$ db [‘db2’] [‘pconnect’] = FALSE;
$ db [‘db2’] [‘db_debug’] = TRUE;
$ db [‘db2’] [‘cache_on’] = FALSE;
$ db [‘db2’] [‘cachedir’] =’‘;
$ db [‘db2’] [‘char_set’] = ‘utf8’;
$ db [‘db2’] [‘dbcollat’] = ‘utf8_general_ci’;
$ db [‘db2’] [‘swap_pre’] =’‘;
$ db [‘db2’] [‘autoinit’] = TRUE;
$ db [‘db2’] [‘stricton’] = FALSE;
model.php here where I refer to the DB2 connection in F1?
m_usuario class extends CI_Model
{
/ / put your code here
function __ construct ()
{
parent :: __construct ();
}
function f1 ()
{
// connection to db2
$ this-> db-> select (‘field1’);
$ this-> db-> select (‘field2’);
$ this-> db-> from (‘table1’);
return $this->db->get()->row_array();
}
}
thanks for all
