connect() connect(mixed $config = array(), boolean|string $name = false) : \think\db\Connection 数据库初始化 并取得数据库类实例 Parameters mixed $config 连接配置 boolean|string $name 连接标识 true 强制重新连接 Throws \think\Exception Returns \think\db\Connection
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
where() where(mixed $field, string $op = null, mixed $condition = null) : \think\db\Query static 查询条件 Parameters mixed $field string $op mixed $condition Returns \think\db\Query
join() join(mixed $join, mixed $condition = null, string $type = 'INNER') : \think\db\Query static JOIN查询 Parameters mixed $join mixed $condition string $type Returns \think\db\Query
union() union(mixed $union, boolean $all = false) : \think\db\Query static UNION查询 Parameters mixed $union boolean $all Returns \think\db\Query
limit() limit(mixed $offset, integer $length = null) : \think\db\Query static 查询LIMIT Parameters mixed $offset integer $length Returns \think\db\Query
order() order(mixed $field, string $order = null) : \think\db\Query static 查询ORDER Parameters mixed $field string $order Returns \think\db\Query
cache() cache(mixed $key = null, integer $expire = null) : \think\db\Query static 设置查询缓存 Parameters mixed $key integer $expire Returns \think\db\Query
column() column(string $field, string $key = '') : array static 获取某个列的值 Parameters string $field string $key Returns array
view() view(mixed $join, mixed $field = null, mixed $on = null, string $type = 'INNER') : \think\db\Query static 视图查询 Parameters mixed $join mixed $field mixed $on string $type Returns \think\db\Query
insert() insert(array $data, boolean $replace = false, boolean $getLastInsID = false, string $sequence = null) : integer static 插入一条记录 Parameters array $data boolean $replace boolean $getLastInsID string $sequence Returns integer
insertGetId() insertGetId(array $data, boolean $replace = false, string $sequence = null) : integer static 插入一条记录并返回自增ID Parameters array $data boolean $replace string $sequence Returns integer
insertAll() insertAll(array $dataSet) : integer static 插入多条记录 Parameters array $dataSet Returns integer
chunk() chunk(integer $count, callable $callback, string $column = null) : boolean static 分块获取数据 Parameters integer $count callable $callback string $column Returns boolean
query() query(string $sql, array $bind = [], boolean $master = false, boolean $pdo = false) : mixed static SQL查询 Parameters string $sql array $bind boolean $master boolean $pdo Returns mixed
execute() execute(string $sql, array $bind = [], boolean $fetch = false, boolean $getLastInsID = false, string $sequence = null) : integer static SQL执行 Parameters string $sql array $bind boolean $fetch boolean $getLastInsID string $sequence Returns integer
paginate() paginate(integer $listRows = 15, mixed $simple = null, array $config = []) : \think\Paginator static 分页查询 Parameters integer $listRows mixed $simple array $config Returns \think\Paginator
transaction() transaction(callable $callback) : mixed static 执行数据库事务 Parameters callable $callback Returns mixed
batchQuery() batchQuery(array $sqlArray) : boolean static 批处理执行SQL语句 Parameters array $sqlArray Returns boolean
getLastInsID() getLastInsID(mixed $sequence = null) : string static 获取最近插入的ID Parameters mixed $sequence Returns string
parseDsn() parseDsn(string $dsnStr) : array DSN解析 格式: mysql://username:passwd@localhost:3306/DbName?param1=val1¶m2=val2#utf8 Parameters string $dsnStr Returns array