connect() connect(mixed $config = [], bool|string $name = false, string $query = '') : mixed 切换数据库连接 Parameters mixed $config 连接配置 bool|string $name 连接标识 true 强制重新连接 string $query 查询对象类名 Throws \think\Exception Returns mixed — 返回查询对象实例
__callStatic() __callStatic(mixed $method, mixed $args) : mixed Parameters mixed $method mixed $args Returns mixed —
readMaster() readMaster(bool $all = false) : \think\db\Query static 后续从主服务器读取数据 Parameters bool $all = false Returns \think\db\Query —
table() table(string $table) : \think\db\Query static 指定数据表(含前缀) Parameters string $table Returns \think\db\Query —
name() name(string $name) : \think\db\Query static 指定数据表(不含前缀) Parameters string $name Returns \think\db\Query —
raw() raw(string $value) : \think\db\Expression static 使用表达式设置数据 Parameters string $value Returns \think\db\Expression —
where() where(mixed $field, string $op = null, mixed $condition = null) : \think\db\Query static 查询条件 Parameters mixed $field string $op = null mixed $condition = null Returns \think\db\Query —
whereRaw() whereRaw(string $where, array $bind = []) : \think\db\Query static 表达式查询 Parameters string $where array $bind = [] Returns \think\db\Query —
whereExp() whereExp(string $field, string $condition, array $bind = []) : \think\db\Query static 字段表达式查询 Parameters string $field string $condition array $bind = [] Returns \think\db\Query —
when() when(mixed $condition, mixed $query, mixed $otherwise = null) : \think\db\Query static 条件查询 Parameters mixed $condition mixed $query mixed $otherwise = null Returns \think\db\Query —
join() join(mixed $join, mixed $condition = null, string $type = 'INNER') : \think\db\Query static JOIN查询 Parameters mixed $join mixed $condition = null string $type = 'INNER' Returns \think\db\Query —
view() view(mixed $join, mixed $field = null, mixed $on = null, string $type = 'INNER') : \think\db\Query static 视图查询 Parameters mixed $join mixed $field = null mixed $on = null string $type = 'INNER' Returns \think\db\Query —
field() field(mixed $field, bool $except = false) : \think\db\Query static 指定查询字段 Parameters mixed $field bool $except = false Returns \think\db\Query —
fieldRaw() fieldRaw(string $field, array $bind = []) : \think\db\Query static 指定查询字段 Parameters string $field array $bind = [] Returns \think\db\Query —
union() union(mixed $union, bool $all = false) : \think\db\Query static UNION查询 Parameters mixed $union bool $all = false Returns \think\db\Query —
limit() limit(mixed $offset, int $length = null) : \think\db\Query static 查询LIMIT Parameters mixed $offset int $length = null Returns \think\db\Query —
order() order(mixed $field, string $order = null) : \think\db\Query static 查询ORDER Parameters mixed $field string $order = null Returns \think\db\Query —
orderRaw() orderRaw(string $field, array $bind = []) : \think\db\Query static 查询ORDER Parameters string $field array $bind = [] Returns \think\db\Query —
cache() cache(mixed $key = null, int $expire = null) : \think\db\Query static 设置查询缓存 Parameters mixed $key = null int $expire = null Returns \think\db\Query —
withAttr() withAttr(string $name, callable $callback = null) : \think\db\Query static 使用获取器获取数据 Parameters string $name callable $callback = null Returns \think\db\Query —
column() column(string $field, string $key = '') : array static 获取某个列的值 Parameters string $field string $key = '' Returns array —
select() select(mixed $data = null) : mixed static 查询多个记录 Parameters mixed $data = null Returns mixed —
insert() insert(array $data, bool $replace = false, bool $getLastInsID = false, string $sequence = null) : int static 插入一条记录 Parameters array $data bool $replace = false bool $getLastInsID = false string $sequence = null Returns int —
insertGetId() insertGetId(array $data, bool $replace = false, string $sequence = null) : int static 插入一条记录并返回自增ID Parameters array $data bool $replace = false string $sequence = null Returns int —
chunk() chunk(int $count, callable $callback, string $column = null) : bool static 分块获取数据 Parameters int $count callable $callback string $column = null Returns bool —
cursor() cursor(mixed $data = null) : \Generator static 使用游标查找记录 Parameters mixed $data = null Returns \Generator —
query() query(string $sql, array $bind = [], bool $master = false, bool $pdo = false) : mixed static SQL查询 Parameters string $sql array $bind = [] bool $master = false bool $pdo = false Returns mixed —
execute() execute(string $sql, array $bind = [], bool $fetch = false, bool $getLastInsID = false, string $sequence = null) : int static SQL执行 Parameters string $sql array $bind = [] bool $fetch = false bool $getLastInsID = false string $sequence = null Returns int —
paginate() paginate(int $listRows = 15, mixed $simple = null, array $config = []) : \think\Paginator static 分页查询 Parameters int $listRows = 15 mixed $simple = null array $config = [] Returns \think\Paginator —
transaction() transaction(callable $callback) : mixed static 执行数据库事务 Parameters callable $callback Returns mixed —
batchQuery() batchQuery(array $sqlArray) : bool static 批处理执行SQL语句 Parameters array $sqlArray Returns bool —
getLastInsID() getLastInsID(string $sequence = null) : string static 获取最近插入的ID Parameters string $sequence = null Returns string —
parseDsnConfig() parseDsnConfig(string $dsnStr) : array DSN解析 格式: mysql://username:passwd@localhost:3306/DbName?param1=val1¶m2=val2#utf8 Parameters string $dsnStr Returns array —