frobou/frobou-db-connect

Frobou 基于 PDO 的连接

1.0.20 2018-01-15 18:51 UTC

README

版本 1.X
SensioLabsInsight

用法

$config = new FrobouPdoConfig(json_decode(file_get_contents(__DIR__ . '/database.json')), true);
$this->con = new FrobouPdoConnection($config, true, $log);
//$ConnectionObject->action($query, 'table1 name (empty for default)');
$query = 'SELECT * FROM table1 limit 1';
$this->con->select($query, 'table1');
$query = 'SELECT * FROM table_default limit 1';
$this->con->select($query);

FrobouPdoConnection 支持事务处理

$this->con->beginTransaction();
$this->con->beginTransaction('table1');
$this->con->beginTransaction('table2');

$query = 'What INTO table (bla-bla-bla) VALUES (bla-bla-bla)';
$this->con->insert($query);
$this->con->update($query, 'table1');
$this->con->delete($query, 'table2');

if (!$this->con->commit()){
    $this->con->rollback();
}
$this->con->commit('radius');
$this->con->commit('postfix');