发布于 2015-08-09 08:48:23 | 880 次阅读 | 评论: 0 | 来源: 网络整理
修改 apps/configs/db.php ,加入配置。
$db['master'] = array(
'type' => SwooleDatabase::TYPE_MYSQLi,
'host' => "127.0.0.1",
'port' => 3306,
'dbms' => 'mysql',
'engine' => 'MyISAM',
'user' => "root",
'passwd' => "root",
'name' => "db_live",
'charset' => "utf8",
'setname' => true,
'persistent' => true,
);
return $db;
单数据库,默认读取master配置
$this->db->query("select * from test");
多数据库,读取制定的数据库配置
$this->db('other_db_config')->query("select * from test");
swoole框架支持3种驱动类型: