\GatewayWorker\LibDbConnection

数据库连接类,依赖 PDO_MYSQL 扩展 在 https://github.com/auraphp/Aura.SqlQuery 的基础上修改而成

Summary

Methods
Properties
Constants
select()
delete()
update()
insert()
calcFoundRows()
cache()
noCache()
straightJoin()
highPriority()
smallResult()
bigResult()
bufferResult()
forUpdate()
distinct()
lowPriority()
ignore()
quick()
delayed()
__toString()
setPaging()
getPaging()
getBindValues()
getBindValuesSELECT()
from()
fromRaw()
fromSubSelect()
join()
innerJoin()
leftJoin()
rightJoin()
joinSubSelect()
groupBy()
having()
orHaving()
page()
union()
unionAll()
where()
orWhere()
limit()
offset()
orderBy()
orderByASC()
orderByDESC()
bindValues()
bindValue()
quoteName()
quoteNamesIn()
setLastInsertIdNames()
into()
getLastInsertIdName()
col()
cols()
set()
table()
getBindValuesCOMMON()
__construct()
closeConnection()
bind()
bindMore()
query()
column()
row()
single()
lastInsertId()
lastSQL()
beginTrans()
commitTrans()
rollBackTrans()
No public properties found
No constants found
addColSELECT()
addColWithAlias()
joinInternal()
fixJoinCondition()
reset()
resetAll()
buildSELECT()
buildDELETE()
buildCols()
buildFrom()
buildGroupBy()
buildHaving()
buildForUpdate()
indentCsv()
indent()
buildFlags()
setFlag()
resetFlags()
addWhere()
addClauseCondWithBind()
buildWhere()
addOrderBy()
buildOrderBy()
buildLimit()
quoteNameWithSeparator()
getListForQuoteNamesIn()
quoteNamesInLoop()
replaceNamesAndAliasIn()
replaceName()
replaceNamesIn()
buildINSERT()
buildInto()
buildValuesForInsert()
build()
buildUPDATE()
buildTable()
buildValuesForUpdate()
addCol()
addCols()
setCol()
addReturning()
buildReturning()
connect()
execute()
$union
$for_update
$cols
$from
$from_key
$group_by
$having
$bind_having
$paging
$bind_values
$where
$bind_where
$order_by
$order_asc
$limit
$offset
$flags
$table
$last_insert_id_names
$col_values
$returning
$type
$pdo
$sQuery
$settings
$parameters
$lastSql
$success
N/A
No private methods found
No private properties found
N/A

Properties

$union

$union : array

SELECT

Type

array

$for_update

$for_update : bool

是否是更新

Type

bool

$cols

$cols : array

选择的列

Type

array

$from

$from : array

从哪些表里面 SELECT

Type

array

$from_key

$from_key : int

$from 当前的 key

Type

int

$group_by

$group_by : array

GROUP BY 的列

Type

array

$having

$having : array

HAVING 条件数组.

Type

array

$bind_having

$bind_having : array

HAVING 语句中绑定的值.

Type

array

$paging

$paging : int

每页多少条记录

Type

int

$bind_values

$bind_values : array

sql 中绑定的值

Type

array

$where

$where : array

WHERE 条件.

Type

array

$bind_where

$bind_where : array

WHERE 语句绑定的值

Type

array

$order_by

$order_by : array

ORDER BY 的列

Type

array

$order_asc

$order_asc : bool

ORDER BY 的排序方式,默认为升序

Type

bool

$limit

$limit : int

SELECT 多少记录

Type

int

$offset

$offset : int

返回记录的游标

Type

int

$flags

$flags : array

flags 列表

Type

array

$table

$table : string

操作哪个表

Type

string

$last_insert_id_names

$last_insert_id_names : array

表.列 和 last-insert-id 映射

Type

array

$col_values

$col_values

INSERT 或者 UPDATE 的列

$returning

$returning : array

返回的列

Type

array

$type

$type : string

sql 的类型 SELECT INSERT DELETE UPDATE

Type

string

$pdo

$pdo : \PDO

pdo 实例

Type

\PDO —

$sQuery

$sQuery : \PDOStatement

PDOStatement 实例

Type

\PDOStatement —

$settings

$settings : array

数据库用户名密码等配置

Type

array

$parameters

$parameters : array

sql 的参数

Type

array

$lastSql

$lastSql : string

最后一条直行的 sql

Type

string

$success

$success : bool

是否执行成功

Type

bool

Methods

select()

select(string|array  $cols = '*') : self

选择哪些列

Parameters

string|array $cols

Returns

self —

delete()

delete(string  $table) : self

从哪个表删除

Parameters

string $table

Returns

self —

update()

update(string  $table) : self

更新哪个表

Parameters

string $table

Returns

self —

insert()

insert(string  $table) : self

向哪个表插入

Parameters

string $table

Returns

self —

calcFoundRows()

calcFoundRows(bool  $enable = true) : self

设置 SQL_CALC_FOUND_ROWS 标记.

Parameters

bool $enable

Returns

self —

cache()

cache(bool  $enable = true) : self

设置 SQL_CACHE 标记

Parameters

bool $enable

Returns

self —

noCache()

noCache(bool  $enable = true) : self

设置 SQL_NO_CACHE 标记

Parameters

bool $enable

Returns

self —

straightJoin()

straightJoin(bool  $enable = true) : self

设置 STRAIGHT_JOIN 标记.

Parameters

bool $enable

Returns

self —

highPriority()

highPriority(bool  $enable = true) : self

设置 HIGH_PRIORITY 标记

Parameters

bool $enable

Returns

self —

smallResult()

smallResult(bool  $enable = true) : self

设置 SQL_SMALL_RESULT 标记

Parameters

bool $enable

Returns

self —

bigResult()

bigResult(bool  $enable = true) : self

设置 SQL_BIG_RESULT 标记

Parameters

bool $enable

Returns

self —

bufferResult()

bufferResult(bool  $enable = true) : self

设置 SQL_BUFFER_RESULT 标记

Parameters

bool $enable

Returns

self —

forUpdate()

forUpdate(bool  $enable = true) : self

设置 FOR UPDATE 标记

Parameters

bool $enable

Returns

self —

distinct()

distinct(bool  $enable = true) : self

设置 DISTINCT 标记

Parameters

bool $enable

Returns

self —

lowPriority()

lowPriority(bool  $enable = true) : self

设置 LOW_PRIORITY 标记

Parameters

bool $enable

Returns

self —

ignore()

ignore(bool  $enable = true) : self

设置 IGNORE 标记

Parameters

bool $enable

Returns

self —

quick()

quick(bool  $enable = true) : self

设置 QUICK 标记

Parameters

bool $enable

Returns

self —

delayed()

delayed(bool  $enable = true) : self

设置 DELAYED 标记

Parameters

bool $enable

Returns

self —

__toString()

__toString() : string

序列化

Returns

string —

setPaging()

setPaging(int  $paging) : self

设置每页多少条记录

Parameters

int $paging

Returns

self —

getPaging()

getPaging() : int

获取每页多少条记录

Returns

int —

getBindValues()

getBindValues() : mixed

获取绑定在占位符上的值

Returns

mixed —

getBindValuesSELECT()

getBindValuesSELECT() : array

获取绑定在占位符上的值

Returns

array —

from()

from(string  $table) : self

from 哪个表

Parameters

string $table

Returns

self —

fromRaw()

fromRaw(string  $table) : self

from的表

Parameters

string $table

Returns

self —

fromSubSelect()

fromSubSelect(string  $table, string  $name) : self

子查询

Parameters

string $table
string $name

The alias name for the sub-select.

Returns

self —

join()

join(string  $table, string  $cond = null, string  $type = '') : self

增加 join 语句

Parameters

string $table
string $cond
string $type

Throws

\Exception

Returns

self —

innerJoin()

innerJoin(string  $table, string  $cond = null) : self

inner join

Parameters

string $table
string $cond

Throws

\Exception

Returns

self —

leftJoin()

leftJoin(string  $table, string  $cond = null) : self

left join

Parameters

string $table
string $cond

Throws

\Exception

Returns

self —

rightJoin()

rightJoin(string  $table, string  $cond = null) : self

right join

Parameters

string $table
string $cond

Throws

\Exception

Returns

self —

joinSubSelect()

joinSubSelect(string  $join, string  $spec, string  $name, string  $cond = null) : self

joinSubSelect

Parameters

string $join

inner, left, natural

string $spec
string $name

sub-select 的别名

string $cond

Throws

\Exception

Returns

self —

groupBy()

groupBy(array  $cols) : self

group by 语句

Parameters

array $cols

Returns

self —

having()

having(string  $cond) : self

having 语句

Parameters

string $cond

Returns

self —

orHaving()

orHaving(string  $cond) : self

or having 语句

Parameters

string $cond

The HAVING condition.

Returns

self —

page()

page(int  $page) : self

设置每页的记录数量

Parameters

int $page

Returns

self —

union()

union() : self

union

Returns

self —

unionAll()

unionAll() : self

unionAll

Returns

self —

where()

where(string|array  $cond) : self

where

Parameters

string|array $cond

Returns

self —

orWhere()

orWhere(string|array  $cond) : self

or where

Parameters

string|array $cond

Returns

self —

limit()

limit(int  $limit) : self

limit

Parameters

int $limit

Returns

self —

offset()

offset(int  $offset) : self

limit offset

Parameters

int $offset

Returns

self —

orderBy()

orderBy(array  $cols) : self

orderby.

Parameters

array $cols

Returns

self —

orderByASC()

orderByASC(array  $cols, bool  $order_asc = true) : self

order by ASC OR DESC

Parameters

array $cols
bool $order_asc

Returns

self —

orderByDESC()

orderByDESC(array  $cols) : self

order by DESC

Parameters

array $cols

Returns

self —

bindValues()

bindValues(array  $bind_values) : self

批量为占位符绑定值

Parameters

array $bind_values

Returns

self —

bindValue()

bindValue(string  $name, mixed  $value) : self

单个为占位符绑定值

Parameters

string $name
mixed $value

Returns

self —

quoteName()

quoteName(string  $spec) : string|array

Quotes

Parameters

string $spec

Returns

string|array —

quoteNamesIn()

quoteNamesIn(string  $text) : string|array

Quotes "table.col" 格式的字符串

Parameters

string $text

Returns

string|array —

setLastInsertIdNames()

setLastInsertIdNames(array  $last_insert_id_names) : mixed

设置 `table.column` 与 last-insert-id 的映射

Parameters

array $last_insert_id_names

Returns

mixed —

into()

into(string  $table) : self

insert into.

Parameters

string $table

Returns

self —

getLastInsertIdName()

getLastInsertIdName(string  $col) : mixed

PDO::lastInsertId()

Parameters

string $col

Returns

mixed —

col()

col(string  $col) : self

设置一列,如果有第二各参数,则把第二个参数绑定在占位符上

Parameters

string $col

Returns

self —

cols()

cols(array  $cols) : self

设置多列

Parameters

array $cols

Returns

self —

set()

set(string  $col, string  $value) : self

直接设置列的值

Parameters

string $col
string $value

Returns

self —

table()

table(string  $table) : self

更新哪个表

Parameters

string $table

Returns

self —

getBindValuesCOMMON()

getBindValuesCOMMON() : array

获取绑定的值

Returns

array —

__construct()

__construct(string  $host, int  $port, string  $user, string  $password, string  $db_name, string  $charset = 'utf8') : mixed

构造函数

Parameters

string $host
int $port
string $user
string $password
string $db_name
string $charset

Returns

mixed —

closeConnection()

closeConnection() : mixed

关闭连接

Returns

mixed —

bind()

bind(string  $para, string  $value) : mixed

绑定

Parameters

string $para
string $value

Returns

mixed —

bindMore()

bindMore(array  $parray) : mixed

绑定多个

Parameters

array $parray

Returns

mixed —

query()

query(string  $query = '', array  $params = null, int  $fetchmode = PDO::FETCH_ASSOC) : mixed

执行 SQL

Parameters

string $query
array $params
int $fetchmode

Returns

mixed —

column()

column(string  $query = '', array  $params = null) : array

返回一列

Parameters

string $query
array $params

Returns

array —

row()

row(string  $query = '', array  $params = null, int  $fetchmode = PDO::FETCH_ASSOC) : array

返回一行

Parameters

string $query
array $params
int $fetchmode

Returns

array —

single()

single(string  $query = '', array  $params = null) : string

返回单个值

Parameters

string $query
array $params

Returns

string —

lastInsertId()

lastInsertId() : string

返回 lastInsertId

Returns

string —

lastSQL()

lastSQL() : string

返回最后一条执行的 sql

Returns

string —

beginTrans()

beginTrans() : mixed

开始事务

Returns

mixed —

commitTrans()

commitTrans() : mixed

提交事务

Returns

mixed —

rollBackTrans()

rollBackTrans() : mixed

事务回滚

Returns

mixed —

addColSELECT()

addColSELECT(mixed  $key, string  $val) : void

SELECT选择哪些列

Parameters

mixed $key
string $val

addColWithAlias()

addColWithAlias(string  $spec) : mixed

SELECT 增加选择的列

Parameters

string $spec

Returns

mixed —

joinInternal()

joinInternal(string  $join, string  $table, string  $cond = null) : self

增加 join 语句

Parameters

string $join

inner, left, natural

string $table
string $cond

Throws

\Exception

Returns

self —

fixJoinCondition()

fixJoinCondition(string  $cond) : string

quote

Parameters

string $cond

Returns

string —

reset()

reset() : mixed

重置

Returns

mixed —

resetAll()

resetAll() : mixed

清除所有数据

Returns

mixed —

buildSELECT()

buildSELECT() : string

创建 SELECT SQL

Returns

string —

buildDELETE()

buildDELETE() : mixed

创建 DELETE SQL

Returns

mixed —

buildCols()

buildCols() : string

生成 SELECT 列语句

Throws

\Exception

Returns

string —

buildFrom()

buildFrom() : string

生成 FROM 语句.

Returns

string —

buildGroupBy()

buildGroupBy() : string

生成 GROUP BY 语句.

Returns

string —

buildHaving()

buildHaving() : string

生成 HAVING 语句.

Returns

string —

buildForUpdate()

buildForUpdate() : string

生成 FOR UPDATE 语句

Returns

string —

indentCsv()

indentCsv(array  $list) : string

返回逗号分隔的字符串

Parameters

array $list

Returns

string —

indent()

indent(array  $list) : string

返回空格分隔的字符串

Parameters

array $list

Returns

string —

buildFlags()

buildFlags() : string

生成 flag

Returns

string —

setFlag()

setFlag(string  $flag, bool  $enable = true) : mixed

设置 flag.

Parameters

string $flag
bool $enable

Returns

mixed —

resetFlags()

resetFlags() : mixed

重置 flag

Returns

mixed —

addWhere()

addWhere(string  $andor, array  $conditions) : self

添加 where 语句

Parameters

string $andor

'AND' or 'OR

array $conditions

Returns

self —

addClauseCondWithBind()

addClauseCondWithBind(string  $clause, string  $andor, array  $conditions) : mixed

添加条件和绑定值

Parameters

string $clause

where 、having等

string $andor

AND、OR等

array $conditions

Returns

mixed —

buildWhere()

buildWhere() : string

生成 where 语句

Returns

string —

addOrderBy()

addOrderBy(array  $spec) : self

增加 order by

Parameters

array $spec

The columns and direction to order by.

Returns

self —

buildOrderBy()

buildOrderBy() : string

生成 order by 语句

Returns

string —

buildLimit()

buildLimit() : string

生成 limit 语句

Returns

string —

quoteNameWithSeparator()

quoteNameWithSeparator(string  $spec, string  $sep, int  $pos) : string

指定分隔符的 Quotes

Parameters

string $spec
string $sep
int $pos

Returns

string —

getListForQuoteNamesIn()

getListForQuoteNamesIn(string  $text) : array

返回 quote 元素列表

Parameters

string $text

Returns

array —

quoteNamesInLoop()

quoteNamesInLoop(string  $val, bool  $is_last) : string

循环 quote

Parameters

string $val
bool $is_last

Returns

string —

replaceNamesAndAliasIn()

replaceNamesAndAliasIn(string  $val) : string

替换成别名

Parameters

string $val

Returns

string —

replaceName()

replaceName(string  $name) : string

Quotes name

Parameters

string $name

Returns

string —

replaceNamesIn()

replaceNamesIn(string  $text) : string|array

Quotes

Parameters

string $text

Returns

string|array —

buildINSERT()

buildINSERT() : string

生成 INSERT 语句

Returns

string —

buildInto()

buildInto() : string

生成 INTO 语句

Returns

string —

buildValuesForInsert()

buildValuesForInsert() : string

为 INSERT 语句绑定值

Returns

string —

build()

build() : string

生成完整 SQL 语句

Throws

\Exception

Returns

string —

buildUPDATE()

buildUPDATE() : mixed

生成更新的 SQL 语句

Returns

mixed —

buildTable()

buildTable() : string

哪个表

Returns

string —

buildValuesForUpdate()

buildValuesForUpdate() : string

为更新语句绑定值

Returns

string —

addCol()

addCol(string  $col) : self

设置列

Parameters

string $col

Returns

self —

addCols()

addCols(array  $cols) : self

设置多个列

Parameters

array $cols

Returns

self —

setCol()

setCol(string  $col, string  $value) : self

设置单列的值

Parameters

string $col

.

string $value

Returns

self —

addReturning()

addReturning(array  $cols) : self

增加返回的列

Parameters

array $cols

Returns

self —

buildReturning()

buildReturning() : string

生成 RETURNING 语句

Returns

string —

connect()

connect() : mixed

创建 PDO 实例

Returns

mixed —

execute()

execute(string  $query, string  $parameters = "") : mixed

执行

Parameters

string $query
string $parameters

Throws

\PDOException

Returns

mixed —