PHP Class Think\Db\Builder

ファイルを表示 Open project: top-think/framework Class Usage Examples

Protected Properties

Property Type Description
$connection connection对象实例
$deleteSql
$exp 数据库表达式
$insertAllSql
$insertSql
$query 查询对象实例
$selectSql SQL表达式
$updateSql

Public Methods

Method Description
__construct ( Connection $connection ) 架构函数
buildWhere ( mixed $where, array $options ) : string 生成查询条件SQL
delete ( array $options ) : string 生成delete SQL
insert ( array $data, array $options = [], boolean $replace = false ) : string 生成insert SQL
insertAll ( array $dataSet, array $options ) : string 生成insertall SQL
select ( array $options = [] ) : string 生成查询SQL
selectInsert ( array $fields, string $table, array $options ) : string 生成slectinsert SQL
setQuery ( Query $query ) : void 设置当前的Query对象实例
update ( $data, array $options ) : string 生成update SQL

Protected Methods

Method Description
parseClosure ( $call, $show = true ) 执行闭包子查询
parseComment ( string $comment ) : string comment分析
parseData ( array $data, array $options ) : array 数据分析
parseDateTime ( string $value, string $key, array $options = [], string $bindName = null, integer $bindType = null ) : string 日期时间条件解析
parseDistinct ( mixed $distinct ) : string distinct分析
parseField ( mixed $fields, array $options = [] ) : string field分析
parseForce ( mixed $index ) : string index分析,可在操作链中指定需要强制使用的索引
parseGroup ( mixed $group ) : string group分析
parseHaving ( string $having ) : string having分析
parseJoin ( array $join, array $options = [] ) : string join分析
parseKey ( string $key, array $options = [] ) : string 字段名分析
parseLimit ( $limit ) : string limit分析
parseLock ( $lock = false ) : string 设置锁机制
parseOrder ( mixed $order, array $options = [] ) : string order分析
parseSqlTable ( string $sql ) : string 将SQL语句中的__TABLE_NAME__字符串替换成带前缀的表名(小写)
parseTable ( mixed $tables, array $options = [] ) : string table分析
parseUnion ( mixed $union ) : string union分析
parseValue ( mixed $value, string $field = '' ) : string | array value分析
parseWhere ( mixed $where, array $options ) : string where分析
parseWhereItem ( $field, $val, $rule = '', $options = [], $binds = [], $bindName = null ) where子单元分析

Method Details

__construct() public method

架构函数
public __construct ( Connection $connection )
$connection Connection 数据库连接对象实例

buildWhere() public method

生成查询条件SQL
public buildWhere ( mixed $where, array $options ) : string
$where mixed
$options array
return string

delete() public method

生成delete SQL
public delete ( array $options ) : string
$options array 表达式
return string

insert() public method

生成insert SQL
public insert ( array $data, array $options = [], boolean $replace = false ) : string
$data array 数据
$options array 表达式
$replace boolean 是否replace
return string

insertAll() public method

生成insertall SQL
public insertAll ( array $dataSet, array $options ) : string
$dataSet array 数据集
$options array 表达式
return string

parseClosure() protected method

执行闭包子查询
protected parseClosure ( $call, $show = true )

parseComment() protected method

comment分析
protected parseComment ( string $comment ) : string
$comment string
return string

parseData() protected method

数据分析
protected parseData ( array $data, array $options ) : array
$data array 数据
$options array 查询参数
return array

parseDateTime() protected method

日期时间条件解析
protected parseDateTime ( string $value, string $key, array $options = [], string $bindName = null, integer $bindType = null ) : string
$value string
$key string
$options array
$bindName string
$bindType integer
return string

parseDistinct() protected method

distinct分析
protected parseDistinct ( mixed $distinct ) : string
$distinct mixed
return string

parseField() protected method

field分析
protected parseField ( mixed $fields, array $options = [] ) : string
$fields mixed
$options array
return string

parseForce() protected method

index分析,可在操作链中指定需要强制使用的索引
protected parseForce ( mixed $index ) : string
$index mixed
return string

parseGroup() protected method

group分析
protected parseGroup ( mixed $group ) : string
$group mixed
return string

parseHaving() protected method

having分析
protected parseHaving ( string $having ) : string
$having string
return string

parseJoin() protected method

join分析
protected parseJoin ( array $join, array $options = [] ) : string
$join array
$options array 查询条件
return string

parseKey() protected method

字段名分析
protected parseKey ( string $key, array $options = [] ) : string
$key string
$options array
return string

parseLimit() protected method

limit分析
protected parseLimit ( $limit ) : string
return string

parseLock() protected method

设置锁机制
protected parseLock ( $lock = false ) : string
return string

parseOrder() protected method

order分析
protected parseOrder ( mixed $order, array $options = [] ) : string
$order mixed
$options array 查询条件
return string

parseSqlTable() protected method

将SQL语句中的__TABLE_NAME__字符串替换成带前缀的表名(小写)
protected parseSqlTable ( string $sql ) : string
$sql string sql语句
return string

parseTable() protected method

table分析
protected parseTable ( mixed $tables, array $options = [] ) : string
$tables mixed
$options array
return string

parseUnion() protected method

union分析
protected parseUnion ( mixed $union ) : string
$union mixed
return string

parseValue() protected method

value分析
protected parseValue ( mixed $value, string $field = '' ) : string | array
$value mixed
$field string
return string | array

parseWhere() protected method

where分析
protected parseWhere ( mixed $where, array $options ) : string
$where mixed 查询条件
$options array 查询参数
return string

parseWhereItem() protected method

where子单元分析
protected parseWhereItem ( $field, $val, $rule = '', $options = [], $binds = [], $bindName = null )

select() public method

生成查询SQL
public select ( array $options = [] ) : string
$options array 表达式
return string

selectInsert() public method

生成slectinsert SQL
public selectInsert ( array $fields, string $table, array $options ) : string
$fields array 数据
$table string 数据表
$options array 表达式
return string

setQuery() public method

设置当前的Query对象实例
public setQuery ( Query $query ) : void
$query Query 当前查询对象实例
return void

update() public method

生成update SQL
public update ( $data, array $options ) : string
$options array 表达式
return string

Property Details

$connection protected_oe property

connection对象实例
protected $connection

$deleteSql protected_oe property

protected $deleteSql

$exp protected_oe property

数据库表达式
protected $exp

$insertAllSql protected_oe property

protected $insertAllSql

$insertSql protected_oe property

protected $insertSql

$query protected_oe property

查询对象实例
protected $query

$selectSql protected_oe property

SQL表达式
protected $selectSql

$updateSql protected_oe property

protected $updateSql