thinkphp3.2配置多个数据库并调用

 

 return array(
	'DB_TYPE'=>'mysql',
	'DB_HOST'=>'localhost',
	'DB_NAME'=>'domain_cc',
	'DB_USER'=>'root',
	'DB_PWD'=>'root',
	'DB_PORT'=>'3306',
	'DB_PREFIX'=>'rockphp_',
    'DB_CONFIG1' => array(
           'db_type'  => 'mysql',
           'db_host'  => 'localhost',
           'db_name'  => 'domain1_cc',
           'db_user'  => 'root',
           'db_pwd'  => 'root',
           'db_port'  => '3306',

		),
    'DB_CONFIG2' => array(
           'db_type'  => 'mysql',
           'db_host'  => 'localhost',
           'db_name'  => 'domain2_cc',
           'db_user'  => 'root',
           'db_pwd'  => 'root',
           'db_port'  => '3306',
           'db_prefix'=>'badcat_',

		)
	
);

调用的方式

$list = M('Picture')->limit(10)->select(); 
$list1 = M('Picture','','DB_CONFIG1')->limit(10)->select(); 
$list2 = M('Picture','badcat_','DB_CONFIG2')->limit(10)->select(); 

 

你可能感兴趣的:(ThinkPHP)