BFWSOA多种数据库的连接方式

BFWSOA多种数据库的连接方式

BFWSOA框架中Model层主要负责对数据库进行持久化,每个model层可以单独连接一个数据库或一张表,相互独立,支持分布式事务处理,读写分离设置

下面我们来演示一下常用的model层连接方式

1、mysql连接方式

$_config_arr['Db']['logicconfig'] = [
    "dbtype" => "DbMysql",
    "dbport" => 3306,
    "dbuser" => "root",
    "dbpwd" => "root",
    "dbname"=>"bfwdbname",
    "dbhost"=>"127.0.0.1"
];

2、sqllite;连接方式

$_config_arr['Db']['sqlconfig'] = [
    "dbtype" => "DbSqlite",
    "dbuser" => "root",
    "dbpwd" => "root",
    "dbname" => "bfwdbname",
    "dbhost" => DATA_DIR,
    "createsql" => "CREATE TABLE IF NOT EXISTS bfw_test (
            id INTEGER PRIMARY KEY,
            username TEXT,
            userpwd TEXT,
            token TEXT,
           regtime TEXT)"
];

3、mssql连接方式

$_config_arr['Db']['mssqlconfig'] = [
    "dbtype" => "DbMssql",
    "dbport" => 1433,
    "dbuser" => "root",
    "dbpwd" => "test",
    "dbname" => "dbname",
    "dbhost" => "127.0.0.1"
];

点击查看剩余70%

{{collectdata}}

网友评论0