mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-23 08:35:35 +08:00
update to 3.2.0, add zm_sqlite() (portable sqlite)
This commit is contained in:
@@ -55,6 +55,9 @@ const ZM_PLUGIN_TYPE_COMPOSER = 3; // Composer 依赖的插件
|
||||
const LOAD_MODE_SRC = 0; // 从 src 加载
|
||||
const LOAD_MODE_VENDOR = 1; // 从 vendor 加载
|
||||
|
||||
const ZM_DB_POOL = 1; // 数据库连接池
|
||||
const ZM_DB_PORTABLE = 2; // SQLite 便携数据库
|
||||
|
||||
/* 定义工作目录 */
|
||||
define('WORKING_DIR', getcwd());
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ use ZM\Plugin\OneBot\BotMap;
|
||||
use ZM\Plugin\ZMPlugin;
|
||||
use ZM\Schedule\Timer;
|
||||
use ZM\Store\Database\DBException;
|
||||
use ZM\Store\Database\DBPool;
|
||||
use ZM\Store\Database\DBQueryBuilder;
|
||||
use ZM\Store\Database\DBWrapper;
|
||||
use ZM\Store\KV\KVInterface;
|
||||
@@ -254,6 +255,32 @@ function sql_builder(string $name = ''): DBQueryBuilder
|
||||
return (new DBWrapper($name))->createQueryBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一个便携 SQLite 操作类
|
||||
*
|
||||
* @param string $name 使用的 SQLite 连接文件名
|
||||
* @param bool $create_new 是否在文件不存在时创建新的
|
||||
* @param bool $keep_alive 是否维持 PDO 对象以便优化性能
|
||||
* @throws DBException
|
||||
*/
|
||||
function zm_sqlite(string $name, bool $create_new = true, bool $keep_alive = true): DBWrapper
|
||||
{
|
||||
return DBPool::createPortableSqlite($name, $create_new, $keep_alive);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取便携 SQLite 操作类的 SQL 语句构造器
|
||||
*
|
||||
* @param string $name 使用的 SQLite 连接文件名
|
||||
* @param bool $create_new 是否在文件不存在时创建新的
|
||||
* @param bool $keep_alive 是否维持 PDO 对象以便优化性能
|
||||
* @throws DBException
|
||||
*/
|
||||
function zm_sqlite_builder(string $name, bool $create_new = true, bool $keep_alive = true): DBQueryBuilder
|
||||
{
|
||||
return zm_sqlite($name, $create_new, $keep_alive)->createQueryBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 Redis 操作类
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user