seleda / dbeasy
v0.0.6
2024-06-10 16:15 UTC
Requires (Dev)
- phpunit/phpunit: ^8.5
README
轻松连接数据库并工作
项目设置
composer require seleda/dbeasy
用法
在调用之前定义全局常量
- _DB_SERVER_
- _DB_USER_
- _DB_PASSWD_
- _DB_NAME_
- _DB_PREFIX_(可选)
或
Seleda\Dbeasy\Db::$_servers = [
[
'server' => '',
'user' => '',
'password' => '',
'database' => ''
]
];
方法
Db::getInstance()->insert('table_without prefix', [
'column' => $value
]);
Db::getInstance()->update('table_without prefix', [
'column' => $value
], 'condition');
Db::getInstance()->delete('table_without prefix', 'condition');
执行查询。
Db::getInstance()->execute($qyery);
执行查询并返回作为数组的$sql结果。
Db::getInstance()->executeS($sql);
返回包含查询第一行的关联数组。此函数会自动将"LIMIT 1"添加到查询中。
Db::getInstance()->getRow($sql);
从SELECT查询的第一行的第一列返回一个值。
Db::getInstance()->getValue($sql);