i'm a newbie with codeigniter
i create an application using codeigniter and i use multiple database connection say:
database1 (default)
database2
when is use a form_validation library using the is_unique rule which require [table_name.column_name]
ex :
$this->form_validation->set_rule('form_field', 'alias', is_unique[target_table.column_name]);
the problem: i want to validate the input form filed against database2, however i use this code in the constructor
$this->database2 = $ci->load->database('database2', true);
codeigniter error Error Number: 1146 Table 'database1.target_table' doesn't exist
where the target_table exist in database2
help me please
The best method would be:
$DB2 = $this->load->database('database2', TRUE);
This now makes "$DB1" the variable which contains your database settings to run active record queries:
$DB2->query();
$DB2->result();
etc...
====================
Also, if both databases are on the same server with the same login etc, you could use this optional parameter:
$this->db->db_select('database2');
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments