取得模型实例对象
static mixed
getInstance
()
架构函数
取得DB类的实例对象 数据表字段检查
Model
__construct
([mixed $data = ''])
新增数据 支持数组、HashMap对象、std对象、数据对象
int
add
([mixed $data = null], [boolean $autoLink = false], [boolean $multi = false])
-
mixed
$data: 数据
-
boolean
$autoLink: 自动关联写入
-
boolean
$multi: 多数据写入
批量新增数据
boolen
addAll
([mixed $dataList = ''], [boolean $autoLink = false])
-
mixed
$dataList: 数据列表
-
boolean
$autoLink: 自动关联操作
增加数据库连接
boolean
addConnect
(mixed $config, mixed $linkNum, [boolean $eqType = true])
-
mixed
$config: 数据库连接信息
-
mixed
$linkNum: 创建的连接序号
-
boolean
$eqType: 是否相同类型连接
统计某个字段的平均值
integer
avg
(string $field, [mixed $condition = ''])
-
string
$field: 字段名
-
mixed
$condition: 条件
查询SQL组装lock
Model
cache
(
$cache,
boolean $lock)
-
boolean
$lock: 是否锁定
-
$cache
记录乐观锁
void
cacheLockVersion
(mixed $data)
检查条件中的视图字段
array
checkCondition
(mixed $data)
检查fields表达式中的视图字段
array
checkFields
(string $fields)
检查Group表达式中的视图字段
array
checkGroup
(string $group)
检查乐观锁
mixed
checkLockVersion
( &$data, [ &$where = ''], array $data, mixed $where)
-
array
$data: 当前数据
-
mixed
$where: 查询条件
-
&$data
-
&$where
检查Order表达式中的视图字段
array
checkOrder
(string $order)
统计满足条件的记录个数
integer
count
([mixed $condition = ''], [string $field = '*'])
-
mixed
$condition: 条件
-
string
$field: 要统计的字段 默认为*
创建数据对象 但不保存到数据库
mixed
create
([mixed $data = ''], [boolean $batch = false], string $type)
-
mixed
$data: 创建数据
-
string
$type: 创建类型
-
boolean
$batch: 批量创建
创建数据列表对象 但不保存到数据库
mixed
createAll
([mixed $dataList = ''], string $type)
-
mixed
$dataList: 数据列表
-
string
$type: 创建类型
删除File方式的字段
void
delBlobFields
( &$data, [string $field = ''], mixed $data)
-
mixed
$data: 保存的数据
-
string
$field: 查询的字段
-
&$data
删除数据库连接
boolean
delConnect
(integer $linkNum)
-
integer
$linkNum: 创建的连接序号
根据条件删除表数据
如果成功返回删除记录个数
boolen
delete
([mixed $data = null], [integer $limit = ''], [string $order = ''], [boolean $autoLink = false])
-
mixed
$data: 删除条件
-
integer
$limit: 要删除的记录数
-
string
$order: 删除的顺序
-
boolean
$autoLink: 是否关联删除
根据条件删除数据
boolen
deleteAll
([mixed $condition = ''], [boolean $autoLink = false])
-
mixed
$condition: 删除条件
-
boolean
$autoLink: 是否关联删除
根据某个字段删除数据
boolen
deleteBy
(string $field, mixed $value, [integer $limit = ''], [string $order = ''], [boolean $autoLink = false])
-
string
$field: 字段名称
-
mixed
$value: 字段值
-
integer
$limit: 要删除的记录数
-
string
$order: 删除的顺序
-
boolean
$autoLink: 是否关联删除
根据主键删除数据
boolen
deleteById
(integer $id, [boolean $autoLink = false])
-
integer
$id: 主键值
-
boolean
$autoLink: 是否关联删除
根据多个主键删除数据
boolen
deleteByIds
(integer $ids, [integer $limit = ''], [string $order = ''], [boolean $autoLink = false])
-
integer
$ids: 多个主键值
-
integer
$limit: 要删除的记录数
-
string
$order: 删除的顺序
-
boolean
$autoLink: 是否关联删除
执行SQL语句
false
execute
([string $sql = ''])
查询SQL组装 field
Model
field
(
string $field)
根据条件得到一条记录
mixed
find
([mixed $condition = ''], [string $fields = '*'], [boolean $cache = false], [mixed $relation = false], [boolean $lazy = false])
-
mixed
$condition: 条件
-
string
$fields: 字段名,默认为*
-
boolean
$cache: 是否读取缓存
-
mixed
$relation: 是否关联查询
-
boolean
$lazy: 是否惰性查询
查找记录
ArrayObject|ResultIterator
findAll
([
mixed $condition =
''], [
string $fields =
'*'], [
string $order =
''], [
string $limit =
''], [
string $group =
''], [
string $having =
''], [
string $join =
''], [
boolean $cache =
false], [
mixed $relation =
false], [
boolean $lazy =
false])
-
mixed
$condition: 条件
-
string
$fields: 查询字段
-
string
$order: 排序
-
string
$limit
-
string
$group
-
string
$having
-
string
$join
-
boolean
$cache: 是否读取缓存
-
mixed
$relation: 是否关联查询
-
boolean
$lazy: 是否惰性查询
获取满足条件的第一条记录
mixed
first
([mixed $condition = ''], [string $order = ''], [string $fields = '*'], [boolean $relation = false])
-
mixed
$condition: 条件
-
string
$fields: 字段名,默认为*
-
string
$order: 排序
-
boolean
$relation: 是否读取关联
获取数据的文本字段
void
getBlobFields
( &$data, [string $field = ''], mixed $data)
-
mixed
$data: 查询的数据
-
string
$field: 查询的字段
-
&$data
根据某个字段得到一条记录
mixed
getBy
(string $field, mixed $value, [string $fields = '*'], [boolean $cache = false], [mixed $relation = false], [boolean $lazy = false])
-
string
$field: 字段名称
-
mixed
$value: 字段的值
-
string
$fields: 字段名,默认为*
-
boolean
$cache: 是否缓存查询
-
mixed
$relation: 是否关联查询
-
boolean
$lazy: 是否惰性查询
根据某个字段获取全部记录
mixed
getByAll
(string $field, mixed $value, [string $fields = '*'], [boolean $cache = false], [mixed $relation = false], [boolean $lazy = true])
-
string
$field: 字段名称
-
mixed
$value: 字段的值
-
string
$fields: 字段名,默认为*
-
boolean
$cache: 是否缓存查询
-
mixed
$relation: 是否关联查询
-
boolean
$lazy: 是否惰性查询
根据主键得到一条记录
mixed
getById
(int $id, [string $fields = '*'], [boolean $cache = false], [mixed $relation = false], [boolean $lazy = false])
-
int
$id: 主键的值
-
string
$fields: 字段名,默认为*
-
boolean
$cache: 是否缓存
-
mixed
$relation: 是否关联读取
-
boolean
$lazy: 是否惰性查询
根据主键范围得到多个记录
mixed
getByIds
(mixed $ids, [string $fields = '*'], [ $order = ''], [ $limit = ''], [boolean $cache = false], [mixed $relation = false], [boolean $lazy = false])
-
mixed
$ids: 主键的范围 如 1,3,4,7 array(1,2,3)
-
string
$fields: 字段名,默认为*
-
boolean
$cache: 是否缓存
-
mixed
$relation: 是否关联读取
-
boolean
$lazy: 是否惰性查询
-
$order
-
$limit
获取查询结果中的某个字段值
mixed
getCol
(ArrayObject $rs, string $field)
-
ArrayObject
$rs: 查询结果
-
string
$field: 字段名
获取查询结果中的多个字段值
mixed
getCols
(ArrayObject $rs, string $field, [ $sepa = ' '], string $spea)
-
ArrayObject
$rs: 查询结果
-
string
$field: 字段名用逗号分割多个
-
string
$spea: 多字段分割符号
-
$sepa
返回数据库字段信息
string
getDbFields
()
返回当前错误信息
string
getError
()
获取一条记录的某个字段值
mixed
getField
(string $field, [mixed $condition = ''])
-
string
$field: 字段名
-
mixed
$condition: 查询条件
获取数据集的个别字段值
array
getFields
(string $field, [mixed $condition = ''], [ $sepa = ' '], string $spea)
-
string
$field: 字段名称
-
mixed
$condition: 条件
-
string
$spea: 多字段分割符号
-
$sepa
获取Iterator因子
Iterate
getIterator
()
Implementation of:
- IteratorAggregate::getIterator
返回最后插入的ID
string
getLastInsID
()
返回最后执行的sql语句
string
getLastSql
()
获取数据集的文本字段
void
getListBlobFields
( &$resultSet, [string $field = ''], mixed $resultSet)
-
mixed
$resultSet: 查询的数据
-
string
$field: 查询的字段
-
&$resultSet
得到当前的数据对象名称
string
getModelName
()
查询符合条件的第N条记录
- 表示第一条记录 -1 表示最后一条记录
mixed
getN
([integer $position = 0], [mixed $condition = ''], [string $order = ''], [string $fields = '*'], [boolean $relation = false])
-
integer
$position: 记录位置
-
mixed
$condition: 条件
-
string
$order: 排序
-
string
$fields: 字段名,默认为*
-
boolean
$relation: 是否读取关联
获取返回数据的关联记录
relation['name'] 关联名称 relation['type'] 关联类型
mixed
getRelation
( &$result, [array $relation = array()], mixed $result)
-
mixed
$result: 返回数据
-
array
$relation: 关联信息
-
&$result
获取返回数据集的关联记录
mixed
getRelations
( &$resultSet, [array $relation = array()], mixed $result)
-
mixed
$result: 返回数据
-
array
$relation: 关联信息
-
&$resultSet
得到关联的数据表名
string
getRelationTableName
(mixed $relation)
得到完整的数据表名
string
getTableName
()
查询SQL组装 group
Model
group
(
string $group)
查询SQL组装 having
Model
having
(
string $having)
获取满足条件的第后一条记录
mixed
last
([mixed $condition = ''], [string $order = ''], [string $fields = '*'], [boolean $relation = false])
-
mixed
$condition: 条件
-
string
$fields: 字段名,默认为*
-
string
$order: 排序
-
boolean
$relation: 是否读取关联
查询SQL组装 惰性
Model
lazy
(
boolean $lazy)
查询SQL组装 limit
Model
limit
(
array $limit)
查询SQL组装lock
Model
lock
(
boolean $lock)
取得某个字段的最大值
integer
max
(string $field, [mixed $condition = ''])
-
string
$field: 字段名
-
mixed
$condition: 条件
取得某个字段的最小值
integer
min
(string $field, [mixed $condition = ''])
-
string
$field: 字段名
-
mixed
$condition: 条件
操作关联数据
mixed
opRelation
(string $opType, mixed $data, [array $relation = array()])
-
string
$opType: 操作方式 ADD SAVE DEL
-
mixed
$data: 数据对象
-
array
$relation: 关联信息
查询SQL组装 order
Model
order
(
string $order)
SQL查询
ArrayObject|ResultIterator
query
(
string $sql, [
boolean $cache =
false], [
boolean $lazy =
false])
-
string
$sql: SQL指令
-
boolean
$cache: 是否缓存
-
boolean
$lazy: 是否惰性查询
把查询结果转换为数据(集)对象
mixed
rsToVo
(mixed $resultSet, [Boolean $returnList = false], [Integer $position = 0], [boolean $relation = ''])
-
mixed
$resultSet: 查询结果记录集
-
Boolean
$returnList: 是否返回记录集
-
Integer
$position: 定位的记录集位置
-
boolean
$relation: 是否获取关联
更新数据
boolen
save
([mixed $data = null], [mixed $where = ''], [boolean $autoLink = false], [integer $limit = 0], [string $order = ''])
-
mixed
$data: 要更新的数据
-
mixed
$where: 更新数据的条件
-
boolean
$autoLink: 自动关联操作
-
integer
$limit: 要更新的记录数
-
string
$order: 更新的顺序
保存File方式的字段
void
saveBlobFields
( &$data, mixed $data)
-
mixed
$data: 保存的数据
-
&$data
字段值减少
boolean
setDec
(string $field, [mixed $condition = ''], [integer $step = 1])
-
string
$field: 字段名
-
mixed
$condition: 条件
-
integer
$step: 减少值
设置记录的某个字段值
支持使用数据库字段和方法 例如 setField('score','(score+1)','id=5');
boolean
setField
(string $field, string $value, [mixed $condition = ''])
-
string
$field: 字段名
-
string
$value: 字段值
-
mixed
$condition: 条件
字段值增长
boolean
setInc
(string $field, [mixed $condition = ''], [integer $step = 1])
-
string
$field: 字段名
-
mixed
$condition: 条件
-
integer
$step: 增长值
统计某个字段的总和
integer
sum
(string $field, [mixed $condition = ''])
-
string
$field: 字段名
-
mixed
$condition: 条件
切换数据库连接
boolean
switchConnect
(integer $linkNum)
-
integer
$linkNum: 创建的连接序号
查询SQL组装 table
Model
table
(
mixed $table)
把数据对象转换成数组
array
toArray
()
查找前N个记录
ArrayObject|ResultIterator
topN
(
integer $count, [
mixed $condition =
''], [
string $fields =
'*'], [
string $order =
''], [
string $group =
''], [
string $having =
''], [
string $join =
''], [
boolean $cache =
false], [
mixed $relation =
false], [
boolean $lazy =
false])
-
integer
$count: 记录个数
-
mixed
$condition: 条件
-
string
$fields: 查询字段
-
string
$order: 排序
-
string
$group
-
string
$having
-
string
$join
-
boolean
$cache: 是否读取缓存
-
mixed
$relation: 是否关联查询
-
boolean
$lazy: 是否惰性查询
查询SQL组装 where
Model
where
(
mixed $where)
根据条件得到一条记录
并且返回关联记录
mixed
xFind
([mixed $condition = ''], [string $fields = '*'], [boolean $cache = false], [boolean $lazy = false])
-
mixed
$condition: 条件
-
string
$fields: 字段名,默认为*
-
boolean
$cache: 是否读取缓存
-
boolean
$lazy: 是否惰性查询
查询记录并返回相应的关联记录
ArrayObject|ResultIterator
xFindAll
([
mixed $condition =
''], [
string $fields =
'*'], [
string $order =
''], [
string $limit =
''], [
string $group =
''], [
string $having =
''], [
string $join =
''], [
boolean $cache =
false],
boolean $lazy)
-
mixed
$condition: 条件
-
string
$fields: 查询字段
-
string
$order: 排序
-
string
$limit
-
string
$group
-
string
$having
-
string
$join
-
boolean
$cache: 是否读取缓存
-
boolean
$lazy: 是否惰性查询
void
_after_create
( &$data)
void
_after_delete
( &$where)
void
_after_operation
( &$data)
void
_after_query
( &$result)
void
_after_read
( &$condition, $result)
void
_after_update
( &$data, $where)
void
_after_validation
( &$data, $type)
void
_before_create
( &$data)
void
_before_delete
( &$where)
void
_before_operation
( &$data)
void
_before_query
( &$sql)
void
_before_read
( &$condition)
void
_before_update
( &$data, $where)
void
_before_validation
( &$data, $type)
对保存到数据库的数据对象进行处理
统一使用数组方式到数据库中间层 facade字段支持
boolean
_facade
(mixed $data)