4d47 / pdo2
该包最新版本(1.0.0)没有可用的许可证信息。
PDO 补充
1.0.0
2013-11-27 02:02 UTC
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2024-09-24 01:05:38 UTC
README
轻量级(5.6KB)的 PDO 包装器,用于加速数据库开发。
用法
$db = new PDO2($yourPdoInstance)
所有 PDO 方法仍然可以直接使用,但实例增加了六个额外的方法。
-
execute(string $statement, array $input_parameters = []) : PDOStatement
$stm = $db->execute("SELECT * FROM wat WHERE id = ?", [12]); // shortcut of $stm = $this->prepare("SELECT * FROM wat WHERE id = ?"); $stm->execute([12]);
-
select($table, $params = [], $extra = '', $values = []) : PDOStatement
$db->select('actors'); $db->select('actors', ['first_name' => 'Al']); $db->select('actors', ['age > ?' => 52]); $db->select('id,age,name from actors', ['age > ?' => 52]); // Associative array creates AND, list array creates OR. $db->select('actors', ['a' => 1, [['b' => 2], ['c' => 3]]]) // SELECT * FROM actors WHERE a = ? AND ((b = ?) OR (c = ?))
-
insert($table, array $params) : PDOStatement
$db->insert('actors', ['first_name' => 'Humphrey', 'last_name' => 'Bogart', 'age' => 57]);
-
update($table, array $params, array $where) : PDOStatement
$db->update('actors', ['first_name' => 'Tommy'], ['id' => 3])
-
delete($table, array $params) : PDOStatement
$db->delete('actors', ['id' => 3]); $db->delete('actors', []); // empty where part cannot be omitted.
-
count($table, array $params = null) : int
$db->count('actors', ['first_name' => 'Tom'])