r-tk / rtk-db
RTK 数据库
dev-master
2018-03-26 20:09 UTC
Requires (Dev)
This package is auto-updated.
Last update: 2024-09-08 15:44:05 UTC
README
数据库连接管理器,具有一些适配器之间的统一
定义连接
use RTK\DB\DB; DB::addInstance('default', array( 'type' => 'mysqli', 'host' => 'localhost', 'user' => 'root', 'password' => '', 'database' => 'test', )); // or DB::addInstance('default', array( 'type' => 'PDOMysql', 'host' => 'localhost', 'user' => 'root', 'password' => '', 'database' => 'test', )); // or DB::addInstance('default', array( 'type' => 'PDOMysql', 'dsn' => 'mysql:dbname=test;host=localhost', 'user' => 'root', 'password' => '', ));
获取连接实例
use RTK\DB\DB; $db = DB::get('default'); // omitting instance name will return instance 'default' $db = DB::get();