不同的模型可以有不同的数据库连接。因此,您的模型使用正常的默认连接 - 但您的“McibModel”模型可以使用另一个连接:
class McibModel extends Model {
protected $connection= 'second_db_connection';
protected $table = 'agencies';
}
然后在您的数据库连接文件中 - 您将有如下内容:
return array(
'connections' => array(
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'database1',
'username' => 'user1',
'password' => 'pass1'
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
'second_db_connection' => array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'database2',
'username' => 'user2',
'password' => 'pass2'
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
),