最后更新 : 2013-11-21 18:11:44
选择语言 :
数据库配置
数据库的配置为 $config['database']
相关配置
配置举例
<?php
$config [ 'database' ][ 'default' ] = array
(
'type' => 'MySQL' ,
'connection' => array
(
'hostname' => 'localhost' ,
'port' => 3306,
'database' => 'myqee' ,
'username' => 'root' ,
'password' => '123456' ,
'persistent' => false,
),
'table_prefix' => 'mq_' ,
'charset' => 'utf8' ,
'caching' => false,
'profiling' => true,
);
|
使用
$db = Database::instance( 'default' );
$db = Database::instance();
|
主从集群配置
array (
'master' => 'm1.test.com' ,
'slaver' => array
(
'm1.test.com' ,
's1.test.com' ,
's1.test.com' ,
's2.test.com' ,
's3.test.com' ,
),
),
|
完整代码示例:
$config [ 'database' ][ 'default' ] = array
(
'type' => 'MySQL' ,
'connection' => array
(
'hostname' => array
(
'master' => 'm1.test.com' ,
'slaver' => array
(
'm1.test.com' ,
's1.test.com' ,
's1.test.com' ,
's2.test.com' ,
's3.test.com' ,
),
),
'port' => 3306,
'database' => 'myqee' ,
'username' => 'root' ,
'password' => '123456' ,
'persistent' => false,
),
'table_prefix' => 'mq_' ,
'charset' => 'utf8' ,
'caching' => false,
'profiling' => true,
);
|