数据库配置
config.php
'DATABASE' => [
//配置项
],
| 配置项 | 默认值 | 类型 | 说明 |
|---|---|---|---|
| driver | pdo | string | 数据库驱动,可选值:pdo,mysqli |
| prefix | string | 表前缀 | |
| charset | utf8 | string | 数据库字符集,不要请置空 |
| persist | false | bool | 是否持久连接 |
| option | [] | array | 数据库选项,因驱动而异 |
| type | mysql | string | 数据库类型,仅对pdo驱动有效 支持类型参见章节:数据库连接 |
| host | localhost | string | 数据库主机 |
| port | 3306 | int | 数据库端口 |
| name | string | 数据库名称 | |
| user | null | string | 数据库用户 |
| pass | null | string | 数据库密码 |
| master | [] | array | 主数据库(集),如设置此项,则表示开启读写分离主从模式,单例模式无需设置。 里面可以直接设置一组服务器信息,也可以设置多组服务器信息(二维数组)。 一组完整设置应该包含:type,charset,persist,option,host,port,name,user,pass字段, 省略的字段系统则使用上面相应的默认字段替代 |
| slave | [] | array | 从数据库(集),含义同master |
| hashtype | 0 | int | 主从模式哈希计算方式,可选值:0=取模,1=随机 |