PHP 클래스 Swoole\Model

저자: Tianfeng Han
파일 보기 프로젝트 열기: matyhtf/swoole_framework 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$_data
$_form
$_form_secret
$_struct
$create_sql
$db swoole\IDatabase
$fields
$foreignkey
$if_cache
$primary
$select
$swoole
$table
$tablesize integer 表切片参数

보호된 프로퍼티들

프로퍼티 타입 설명
$_table_before_shard

공개 메소드들

메소드 설명
__construct ( Swoole $swoole, string $db_key = 'master' ) 构造函数
all ( ) : RecordSet 获取到所有表记录的接口,通过这个接口可以访问到数据库的记录
checkForm ( $input, $method, string &$error ) : true
count ( array $params ) : true/false 返回符合条件的记录数
createTable ( ) : boolean 建立表,必须在Model类中,指定create_sql
del ( $id, $where = null ) : true/false 删除一条数据主键为$id的记录,
dels ( $params ) : boolean 删除一条数据包含多个参数
desc ( ) : array 获取表的字段描述
exists ( $gets ) : boolean 检测是否存在数据,实际可以用count代替,0为false,>0为true
get ( $object_id, $where = '' ) : Record 获取主键$primary_key为$object_id的一条记录对象(Record Object) 如果参数为空的话,则返回一条空白的Record,可以赋值,产生一条新的记录
getForm ( $set_id ) : unknown_type 自动生成表单
getList ( &$params, $get = 'data' ) : array 获取一个数据列表,功能类似于gets,此方法仅用于SiaoCMS,不作为同样类库的方法
getMap ( $gets, $field = null ) : array 获取一个键值对应的结构,键为表记录主键的值,值为记录数据或者其中一个字段的值
getStatus ( ) : array 获取表状态
getTree ( $gets, $category = 'fid', $order = 'id desc' ) : unknown_type 获取一个2层的树状结构
gets ( $params, &$pager = null ) : array 获取表的一段数据,查询的参数由$params指定
parseForm ( )
put ( $data ) : integer 插入一条新的记录到表
set ( $id, $data, $where = '' ) : boolean 更新ID为$id的记录,值为$data关联数组
sets ( array $data, array $params ) : boolean 更新一组数据
shard_table ( $id ) : null 按ID切分表

메소드 상세

__construct() 공개 메소드

构造函数
public __construct ( Swoole $swoole, string $db_key = 'master' )
$swoole Swoole
$db_key string 选择哪个数据库

all() 공개 메소드

获取到所有表记录的接口,通过这个接口可以访问到数据库的记录
public all ( ) : RecordSet
리턴 RecordSet Object (这是一个接口,不包含实际的数据)

checkForm() 공개 메소드

public checkForm ( $input, $method, string &$error ) : true
$error string 出错时设置
리턴 true or false

count() 공개 메소드

返回符合条件的记录数
public count ( array $params ) : true/false
$params array
리턴 true/false

createTable() 공개 메소드

建立表,必须在Model类中,指定create_sql
public createTable ( ) : boolean
리턴 boolean

del() 공개 메소드

删除一条数据主键为$id的记录,
public del ( $id, $where = null ) : true/false
$id
$where string 指定匹配字段,默认为主键
리턴 true/false

dels() 공개 메소드

删除一条数据包含多个参数
public dels ( $params ) : boolean
$params
리턴 boolean

desc() 공개 메소드

获取表的字段描述
public desc ( ) : array
리턴 array

exists() 공개 메소드

检测是否存在数据,实际可以用count代替,0为false,>0为true
public exists ( $gets ) : boolean
$gets
리턴 boolean

get() 공개 메소드

获取主键$primary_key为$object_id的一条记录对象(Record Object) 如果参数为空的话,则返回一条空白的Record,可以赋值,产生一条新的记录
public get ( $object_id, $where = '' ) : Record
$object_id
$where
리턴 Record Object

getForm() 공개 메소드

自动生成表单
public getForm ( $set_id ) : unknown_type
$set_id
리턴 unknown_type

getList() 공개 메소드

获取一个数据列表,功能类似于gets,此方法仅用于SiaoCMS,不作为同样类库的方法
public getList ( &$params, $get = 'data' ) : array
$params
$get
리턴 array

getMap() 공개 메소드

获取一个键值对应的结构,键为表记录主键的值,值为记录数据或者其中一个字段的值
public getMap ( $gets, $field = null ) : array
$gets
$field
리턴 array

getStatus() 최종 공개 메소드

获取表状态
final public getStatus ( ) : array
리턴 array 表的status,包含了自增ID,计数器等状态数据

getTree() 공개 메소드

获取一个2层的树状结构
public getTree ( $gets, $category = 'fid', $order = 'id desc' ) : unknown_type
$gets
$category
$order
리턴 unknown_type

gets() 공개 메소드

获取表的一段数据,查询的参数由$params指定
public gets ( $params, &$pager = null ) : array
$params
$pager Pager
리턴 array

parseForm() 공개 메소드

public parseForm ( )

put() 공개 메소드

插入一条新的记录到表
public put ( $data ) : integer
$data Array 必须是键值(表的字段对应值)对应
리턴 integer

set() 공개 메소드

更新ID为$id的记录,值为$data关联数组
public set ( $id, $data, $where = '' ) : boolean
$id
$data
$where string 指定匹配字段,默认为主键
리턴 boolean

sets() 공개 메소드

更新一组数据
public sets ( array $data, array $params ) : boolean
$data array 更新的数据
$params array update的参数列表
리턴 boolean

shard_table() 공개 메소드

按ID切分表
public shard_table ( $id ) : null
$id
리턴 null

프로퍼티 상세

$_data 공개적으로 프로퍼티

public $_data

$_form 공개적으로 프로퍼티

public $_form

$_form_secret 공개적으로 프로퍼티

public $_form_secret

$_struct 공개적으로 프로퍼티

public $_struct

$_table_before_shard 보호되어 있는 프로퍼티

protected $_table_before_shard

$create_sql 공개적으로 프로퍼티

public $create_sql

$db 공개적으로 프로퍼티

public IDatabase,swoole $db
리턴 swoole\IDatabase

$fields 공개적으로 프로퍼티

public $fields

$foreignkey 공개적으로 프로퍼티

public $foreignkey

$if_cache 공개적으로 프로퍼티

public $if_cache

$primary 공개적으로 프로퍼티

public $primary

$select 공개적으로 프로퍼티

public $select

$swoole 공개적으로 프로퍼티

public $swoole

$table 공개적으로 프로퍼티

public $table

$tablesize 공개적으로 프로퍼티

表切片参数
public int $tablesize
리턴 integer