系统类库
[ 查看开发文档 ] [ 类树图: Library ] [ 索引: Library ] [ 所有元素 ] [ 首页 ]

Class: Model

源文件路径: /Library/Model.class.php

Class Overview


Model模型类 实现了ORM和ActiveRecords模式


Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 10]
Model模型类 实现了ORM和ActiveRecords模式


[ Top ]


Class Variables

$autoCheckFields = true

[line 53]

  • Access: protected

Type:   mixed


[ Top ]

$autoinc = false

[line 26]

  • Access: protected

Type:   mixed


[ Top ]

$connection = ''

[line 34]

  • Access: protected

Type:   mixed


[ Top ]

$data = array()

[line 44]

  • Access: protected

Type:   mixed


[ Top ]

$db = null

[line 20]

  • Access: protected

Type:   mixed


[ Top ]

$dbName = ''

[line 32]

  • Access: protected

Type:   mixed


[ Top ]

$error = ''

[line 40]

  • Access: protected

Type:   mixed


[ Top ]

$fields = array()

[line 42]

  • Access: protected

Type:   mixed


[ Top ]

$methods = array('strict','order','alias','having','group','lock','distinct','auto','filter','validate','result','token','index','force')

[line 59]

  • Access: protected

Type:   mixed


[ Top ]

$name = ''

[line 30]

  • Access: protected

Type:   mixed


[ Top ]

$options = array()

[line 46]

  • Access: protected

Type:   mixed


[ Top ]

$patchValidate = false

[line 57]

  • Access: protected

Type:   mixed


[ Top ]

$pk = 'id'

[line 24]

  • Access: protected

Type:   mixed


[ Top ]

$stripSlashes = false

[line 55]

  • Access: protected

Type:   mixed


[ Top ]

$tableName = ''

[line 36]

  • Access: protected

Type:   mixed


[ Top ]

$tablePrefix = null

[line 28]

  • Access: protected

Type:   mixed


[ Top ]

$trueTableName = ''

[line 38]

  • Access: protected

Type:   mixed


[ Top ]

$_auto = array()

[line 48]

  • Access: protected

Type:   mixed


[ Top ]

$_map = array()

[line 49]

  • Access: protected

Type:   mixed


[ Top ]

$_scope = array()

[line 50]

  • Access: protected

Type:   mixed


[ Top ]

$_validate = array()

[line 47]

  • Access: protected

Type:   mixed


[ Top ]



Method Detail

__construct (Constructor)   [line 69]

Model __construct( [string $name = ''], [string $tablePrefix = ''], [mixed $connection = ''])

架构函数 取得DB类的实例对象 字段检查
  • Access: public

Parameters:

string   $name   —  模型名称
string   $tablePrefix   —  表前缀
mixed   $connection   —  数据库连接信息

[ Top ]

add   [line 340]

mixed add( [mixed $data = ''], [array $options = array()], [boolean $replace = false])

新增数据
  • Access: public

Parameters:

mixed   $data   —  数据
array   $options   —  表达式
boolean   $replace   —  是否replace

[ Top ]

addAll   [line 390]

void addAll( $dataList, [ $options = array()], [ $replace = false])

  • Access: public

Parameters:

   $dataList   — 
   $options   — 
   $replace   — 

[ Top ]

autoCheckToken   [line 1175]

void autoCheckToken( $data)

  • Access: public

Parameters:

   $data   — 

[ Top ]

autoValidation   [line 1295]

boolean autoValidation( array $data, string $type)

自动表单验证
  • Access: protected

Parameters:

array   $data   —  创建数据
string   $type   —  创建类型

[ Top ]

bind   [line 2107]

Model bind( string $key, [mixed $value = false])

参数绑定
  • Access: public

Parameters:

string   $key   —  参数名
mixed   $value   —  绑定的变量及绑定参数

[ Top ]

buildSql   [line 691]

string buildSql( )

生成查询SQL 可用于子查询
  • Access: public

[ Top ]

cache   [line 1929]

Model cache( [mixed $key = true], [integer $expire = null], [string $type = ''])

查询缓存
  • Access: public

Parameters:

mixed   $key   — 
integer   $expire   — 
string   $type   — 

[ Top ]

check   [line 1432]

boolean check( string $value, mixed $rule, [string $type = 'regex'])

验证数据 支持 in between equal length regex expire ip_allow ip_deny
  • Access: public

Parameters:

string   $value   —  验证数据
mixed   $rule   —  验证表达式
string   $type   —  验证方式 默认为正则验证

[ Top ]

comment   [line 2082]

Model comment( string $comment)

查询注释
  • Access: public

Parameters:

string   $comment   —  注释

[ Top ]

commit   [line 1683]

boolean commit( )

提交事务
  • Access: public

[ Top ]

create   [line 1096]

mixed create( mixed $data, [string $type = ''])

创建数据对象 但不保存到数据库
  • Access: public

Parameters:

mixed   $data   —  创建数据
string   $type   —  状态

[ Top ]

data   [line 1811]

Model data( [mixed $data = ''])

设置数据对象值
  • Access: public

Parameters:

mixed   $data   —  数据

[ Top ]

db   [line 1590]

Model db( [integer $linkNum = ''], [mixed $config = ''], [boolean $force = false])

切换当前的数据库连接
  • Access: public

Parameters:

integer   $linkNum   —  连接序号
mixed   $config   —  数据库连接信息
boolean   $force   —  强制重新连接

[ Top ]

delete   [line 523]

mixed delete( [mixed $options = array()])

删除数据
  • Access: public

Parameters:

mixed   $options   —  表达式

[ Top ]

escapeTable   [line 1537]

string escapeTable( string $sql, [ $isTable = true])

过滤SQL语句中的表字段名称
  • Access: protected

Parameters:

string   $sql   — 
   $isTable   — 

[ Top ]

execute   [line 1522]

false execute( string $sql, [mixed $parse = false])

执行SQL语句
  • Return: | integer
  • Access: public

Parameters:

string   $sql   —  SQL指令
mixed   $parse   —  是否需要解析SQL

[ Top ]

fetchSql   [line 2094]

Model fetchSql( [boolean $fetch = true])

获取执行的SQL语句
  • Access: public

Parameters:

boolean   $fetch   —  是否返回sql

[ Top ]

field   [line 1952]

Model field( mixed $field, [boolean $except = false])

指定查询字段 支持字段排除
  • Access: public

Parameters:

mixed   $field   — 
boolean   $except   —  是否排除

[ Top ]

find   [line 800]

mixed find( [mixed $options = array()])

查询数据
  • Access: public

Parameters:

mixed   $options   —  表达式参数

[ Top ]

flush   [line 156]

void flush( )

获取字段信息并缓存
  • Access: public

[ Top ]

getDbError   [line 1713]

string getDbError( )

返回数据库的错误信息
  • Access: public

[ Top ]

getDbFieldInfos   [line 1786]

array getDbFieldInfos( )

获取数据表字段详细信息
  • Access: public

[ Top ]

getDbFields   [line 1758]

array getDbFields( )

获取数据表字段信息
  • Access: public

[ Top ]

getError   [line 1703]

string getError( )

返回模型的错误信息
  • Access: public

[ Top ]

getField   [line 1012]

mixed getField( string $field, [ $sepa = null], string $spea)

获取一条记录的某个字段值
  • Access: public

Parameters:

string   $field   —  字段名
string   $spea   —  字段数据间隔符号 NULL返回数组
   $sepa   — 

[ Top ]

getLastInsID   [line 1723]

string getLastInsID( )

返回最后插入的ID
  • Access: public

[ Top ]

getLastSql   [line 1733]

string getLastSql( )

返回最后执行的sql语句
  • Access: public

[ Top ]

getModelName   [line 1623]

string getModelName( )

得到当前的数据对象名称
  • Access: public

[ Top ]

getPk   [line 1748]

string getPk( )

获取主键名称
  • Access: public

[ Top ]

getTableName   [line 1643]

string getTableName( [bool $isTrue = true])

得到完整的数据表名
  • Access: public

Parameters:

bool   $isTrue   —  是否获取真实表名,默认为true(真实表名为包括数据库和前缀)

[ Top ]

join   [line 1871]

Model join( mixed $join, [string $type = 'INNER'])

查询SQL组装 join
  • Access: public

Parameters:

mixed   $join   — 
string   $type   —  JOIN类型

[ Top ]

lazyWrite   [line 983]

false|integer lazyWrite( string $guid, integer $step, integer $lazyTime)

延时更新检查 返回false表示需要延时 否则返回实际写入的数值
  • Access: protected

Parameters:

string   $guid   —  写入标识
integer   $step   —  写入步进值
integer   $lazyTime   —  延时时间(s)

[ Top ]

limit   [line 2048]

Model limit( mixed $offset, [mixed $length = null])

指定查询数量
  • Access: public

Parameters:

mixed   $offset   —  起始位置
mixed   $length   —  查询数量

[ Top ]

offsetExists   [line 2140]

void offsetExists( $offset)

  • Access: public

Parameters:

   $offset   — 

[ Top ]

offsetGet   [line 2143]

void offsetGet( $offset)

  • Access: public

Parameters:

   $offset   — 

[ Top ]

offsetSet   [line 2146]

void offsetSet( $offset, $value)

  • Access: public

Parameters:

   $offset   — 
   $value   — 

[ Top ]

offsetUnset   [line 2149]

void offsetUnset( $offset)

  • Access: public

Parameters:

   $offset   — 

[ Top ]

page   [line 2064]

Model page( mixed $page, [mixed $listRows = null])

指定分页
  • Access: public

Parameters:

mixed   $page   —  页数
mixed   $listRows   —  每页数量

[ Top ]

parseFieldsMap   [line 891]

array parseFieldsMap( array $data, [integer $type = 1])

处理字段映射
  • Access: public

Parameters:

array   $data   —  当前数据
integer   $type   —  类型 0 写入 1 读取

[ Top ]

parseSql   [line 1563]

string parseSql( string $sql, boolean $parse)

解析SQL语句
  • Access: protected

Parameters:

string   $sql   —  SQL指令
boolean   $parse   —  是否需要解析SQL

[ Top ]

query   [line 1486]

mixed query( string $sql, [mixed $parse = false])

SQL查询
  • Access: public

Parameters:

string   $sql   —  SQL指令
mixed   $parse   —  是否需要解析SQL

[ Top ]

regex   [line 1207]

boolean regex( string $value, string $rule)

使用正则验证数据
  • Access: public

Parameters:

string   $value   —  要验证的数据
string   $rule   —  验证规则

[ Top ]

returnResult   [line 868]

void returnResult( $data, [ $type = ''])

  • Access: protected

Parameters:

   $data   — 
   $type   — 

[ Top ]

rollback   [line 1693]

boolean rollback( )

事务回滚
  • Access: public

[ Top ]

save   [line 443]

boolean save( [mixed $data = ''], [array $options = array()])

保存数据
  • Access: public

Parameters:

mixed   $data   —  数据
array   $options   —  表达式

[ Top ]

scope   [line 1975]

Model scope( [mixed $scope = ''], [array $args = NULL])

调用命名范围
  • Access: public

Parameters:

mixed   $scope   —  命名范围名称 支持多个 和直接定义
array   $args   —  参数

[ Top ]

select   [line 602]

mixed select( [array $options = array()])

查询数据集
  • Access: public

Parameters:

array   $options   —  表达式参数

[ Top ]

selectAdd   [line 421]

boolean selectAdd( [string $fields = ''], [string $table = ''], [array $options = array()])

通过Select方式添加记录
  • Access: public

Parameters:

string   $fields   —  要插入的数据表字段名
string   $table   —  要插入的数据表名
array   $options   —  表达式

[ Top ]

setDec   [line 960]

boolean setDec( string $field, [integer $step = 1], [integer $lazyTime = 0])

字段值减少
  • Access: public

Parameters:

string   $field   —  字段名
integer   $step   —  减少值
integer   $lazyTime   —  延时时间(s)

[ Top ]

setField   [line 919]

boolean setField( string|array $field, [string $value = ''])

设置记录的某个字段值 支持使用数据库字段和方法
  • Access: public

Parameters:

string|array   $field   —  字段名
string   $value   —  字段值

[ Top ]

setInc   [line 937]

boolean setInc( string $field, [integer $step = 1], [integer $lazyTime = 0])

字段值增长
  • Access: public

Parameters:

string   $field   —  字段名
integer   $step   —  增长值
integer   $lazyTime   —  延时时间(s)

[ Top ]

setProperty   [line 2132]

Model setProperty( string $name, mixed $value)

设置模型的属性值
  • Access: public

Parameters:

string   $name   —  名称
mixed   $value   — 

[ Top ]

startTrans   [line 1671]

void startTrans( )

启动事务
  • Access: public

[ Top ]

table   [line 1833]

Model table( mixed $table)

指定当前的数据表
  • Access: public

Parameters:

mixed   $table   — 

[ Top ]

union   [line 1894]

Model union( mixed $union, [boolean $all = false])

查询SQL组装 union
  • Access: public

Parameters:

mixed   $union   — 
boolean   $all   — 

[ Top ]

using   [line 1854]

Model using( mixed $using)

USING支持 用于多表删除
  • Access: public

Parameters:

mixed   $using   — 

[ Top ]

where   [line 2012]

Model where( mixed $where, [mixed $parse = null])

指定查询条件 支持安全过滤
  • Access: public

Parameters:

mixed   $where   —  条件表达式
mixed   $parse   —  预处理参数

[ Top ]

_after_db   [line 1614]

void _after_db( )

  • Access: protected

[ Top ]

_after_delete   [line 592]

void _after_delete( $data, $options)

  • Access: protected

Parameters:

   $data   — 
   $options   — 

[ Top ]

_after_find   [line 865]

void _after_find( &$result, $options)

  • Access: protected

Parameters:

   &$result   — 
   $options   — 

[ Top ]

_after_insert   [line 387]

void _after_insert( $data, $options)

  • Access: protected

Parameters:

   $data   — 
   $options   — 

[ Top ]

_after_select   [line 682]

void _after_select( &$resultSet, $options)

  • Access: protected

Parameters:

   &$resultSet   — 
   $options   — 

[ Top ]

_after_update   [line 513]

void _after_update( $data, $options)

  • Access: protected

Parameters:

   $data   — 
   $options   — 

[ Top ]

_before_delete   [line 588]

void _before_delete( $options)

  • Access: protected

Parameters:

   $options   — 

[ Top ]

_before_insert   [line 383]

void _before_insert( &$data, $options)

  • Access: protected

Parameters:

   &$data   — 
   $options   — 

[ Top ]

_before_update   [line 509]

void _before_update( &$data, $options)

  • Access: protected

Parameters:

   &$data   — 
   $options   — 

[ Top ]

_before_write   [line 328]

void _before_write( &$data)

  • Access: protected

Parameters:

   &$data   — 

[ Top ]

_checkTableInfo   [line 129]

void _checkTableInfo( )

自动检测数据表信息
  • Access: protected

[ Top ]

_facade   [line 292]

boolean _facade( mixed $data)

对保存到数据库的数据进行处理
  • Access: protected

Parameters:

mixed   $data   —  要操作的数据

[ Top ]

_initialize   [line 282]

void _initialize( )

  • Access: protected

[ Top ]

_options_filter   [line 747]

void _options_filter( &$options)

  • Access: protected

Parameters:

   &$options   — 

[ Top ]

_parseOptions   [line 702]

array _parseOptions( [array $options = array()])

分析表达式
  • Access: protected

Parameters:

array   $options   —  表达式参数

[ Top ]

_parseType   [line 758]

void _parseType( &$data, string $key, mixed $data)

数据类型检测
  • Access: protected

Parameters:

mixed   $data   —  数据
string   $key   —  字段名
   &$data   — 

[ Top ]

_read_data   [line 780]

array _read_data( array $data)

数据读取后的处理
  • Access: protected

Parameters:

array   $data   —  当前数据

[ Top ]

_sql   [line 1738]

void _sql( )

  • Access: public

[ Top ]

_validationField   [line 1350]

boolean _validationField( array $data, array $val)

验证表单字段 支持批量验证 如果批量验证返回错误的数组信息
  • Access: protected

Parameters:

array   $data   —  创建数据
array   $val   —  验证因子

[ Top ]

_validationFieldItem   [line 1372]

boolean _validationFieldItem( array $data, array $val)

根据验证因子验证字段
  • Access: protected

Parameters:

array   $data   —  创建数据
array   $val   —  验证因子

[ Top ]

__call   [line 252]

mixed __call( string $method, array $args)

利用__call方法实现一些特殊的Model方法
  • Access: public

Parameters:

string   $method   —  方法名称
array   $args   —  调用参数

[ Top ]

__get   [line 218]

mixed __get( string $name)

获取数据对象的值
  • Access: public

Parameters:

string   $name   —  名称

[ Top ]

__isset   [line 229]

boolean __isset( string $name)

检测数据对象的值
  • Access: public

Parameters:

string   $name   —  名称

[ Top ]

__set   [line 206]

void __set( string $name, mixed $value)

设置数据对象的值
  • Access: public

Parameters:

string   $name   —  名称
mixed   $value   — 

[ Top ]

__unset   [line 240]

void __unset( string $name)

销毁数据对象的值
  • Access: public

Parameters:

string   $name   —  名称

[ Top ]


Powered by Steeze. author email: spring.wind2006@163.com