PHP 클래스 Sprig_Core, sprig

저자: Woody Gilk
파일 보기 프로젝트 열기: sittercity/sprig 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_changed Changed object data
$_db database instance name
$_fields field list (name => object)
$_init Initialization status
$_model model name
$_original Original object data
$_primary_key primary key string or array (for composite keys)
$_related Related object data
$_relations Model many-to-many relations
$_sorting default sorting parameters
$_state Object state
$_table database table name
$_title_key title key string (for select lists)

공개 메소드들

메소드 설명
__get ( $name ) : mixed Get the value of a field.
__isset ( $name ) : boolean Check if a value exists within the mode.
__set ( $name, $value ) : void Set the value of a field.
__sleep ( ) : array Allow serialization of initialized object containing related objects as a Database_Result
__toString ( ) : string Returns the model name.
__unset ( $name ) : void Unset the changed the value of a field.
_unique_field ( Validate $array, $field ) : void Callback for validating unique fields.
as_array ( $verbose = FALSE ) : array Get the model data as an associative array.
changed ( $field = NULL ) : array Get all of the changed fields as an associative array.
check ( array $data = NULL ) : array Check the given data is valid. Only values that have editable fields will be included and checked.
count ( Database_Query_Builder_Select $query = NULL ) Count the number of records using the current data.
create ( ) Create a new record using the current data.
db ( $db = NULL ) : string Gets and sets the database instance used for this model.
delete ( Database_Query_Builder_Delete $query = NULL ) Delete the current record:
factory ( $name, array $values = NULL ) : Sprig Load an empty sprig model.
field ( $name ) : Sprig_Field Get a single field object.
fields ( ) : array Get all fields as an associative array.
fk ( $table = NULL ) : string Returns the foreign key of the model, optionally with a table name.
input ( $name, array $attr = NULL ) : string Return a single field input.
inputs ( $labels = TRUE ) : array Get all fields as an array of inputs.
label ( $field, array $attr = NULL ) : string Return a single field label.
load ( Database_Query_Builder_Select $query = NULL, $limit = 1 ) Load a single record using the current data.
loaded ( ) : boolean Object data loaded status.
pk ( $table = NULL ) : string Returns the primary key of the model, optionally with a table name.
relate ( $name, $value ) Adds a relationship to the model
related ( $name, $value ) : boolean Determines if this object has a relation
select_list ( $key = NULL, $value = NULL ) : array Get all of the records for this table as an associative array.
state ( $state = NULL ) : string Get or set the model status.
table ( $table = NULL ) : string Gets and sets the table name of the model.
tk ( $table = NULL ) : string Returns the title key of the model, optionally with a table name.
unrelate ( $name, $value ) Removes a relationship to the model
update ( ) Update the current record using the current data.
values ( array $values ) Load all of the values in an associative array. Ignores all fields are not in the model.
verbose ( $field ) : string Return a single field value in verbose form.

보호된 메소드들

메소드 설명
__construct ( ) : void Initialize the fields and add validation rules based on field properties.
_init ( ) : void Initialize the fields. This method will only be called once by Sprig::init(). All models must define this method!

메소드 상세

__construct() 보호된 메소드

Initialize the fields and add validation rules based on field properties.
protected __construct ( ) : void
리턴 void

__get() 공개 메소드

Get the value of a field.
public __get ( $name ) : mixed
리턴 mixed

__isset() 공개 메소드

Check if a value exists within the mode.
public __isset ( $name ) : boolean
리턴 boolean

__set() 공개 메소드

Set the value of a field.
public __set ( $name, $value ) : void
리턴 void

__sleep() 공개 메소드

Allow serialization of initialized object containing related objects as a Database_Result
public __sleep ( ) : array
리턴 array list of properties to serialize

__toString() 공개 메소드

Returns the model name.
public __toString ( ) : string
리턴 string

__unset() 공개 메소드

Unset the changed the value of a field.
public __unset ( $name ) : void
리턴 void

_init() 추상적인 보호된 메소드

Initialize the fields. This method will only be called once by Sprig::init(). All models must define this method!
abstract protected _init ( ) : void
리턴 void

_unique_field() 공개 메소드

Callback for validating unique fields.
public _unique_field ( Validate $array, $field ) : void
$array Validate
리턴 void

as_array() 공개 메소드

Get the model data as an associative array.
public as_array ( $verbose = FALSE ) : array
리턴 array field => value

changed() 공개 메소드

Get all of the changed fields as an associative array.
public changed ( $field = NULL ) : array
리턴 array field => value

check() 공개 메소드

Check the given data is valid. Only values that have editable fields will be included and checked.
public check ( array $data = NULL ) : array
$data array
리턴 array filtered data

count() 공개 메소드

Count the number of records using the current data.
public count ( Database_Query_Builder_Select $query = NULL )
$query Database_Query_Builder_Select

create() 공개 메소드

Create a new record using the current data.
public create ( )

db() 공개 메소드

Gets and sets the database instance used for this model.
public db ( $db = NULL ) : string
리턴 string

delete() 공개 메소드

- If the record is loaded, it will be deleted using primary key(s). - If the record is not loaded, it will be deleted using all changed fields. - If no data has been changed, the delete will be ignored.
public delete ( Database_Query_Builder_Delete $query = NULL )
$query Database_Query_Builder_Delete

factory() 공개 정적인 메소드

Load an empty sprig model.
public static factory ( $name, array $values = NULL ) : Sprig
$values array
리턴 Sprig

field() 공개 메소드

Get a single field object.
public field ( $name ) : Sprig_Field
리턴 Sprig_Field

fields() 공개 메소드

Get all fields as an associative array.
public fields ( ) : array
리턴 array name => object

fk() 공개 메소드

Returns the foreign key of the model, optionally with a table name.
public fk ( $table = NULL ) : string
리턴 string

input() 공개 메소드

Return a single field input.
public input ( $name, array $attr = NULL ) : string
$attr array
리턴 string

inputs() 공개 메소드

Get all fields as an array of inputs.
public inputs ( $labels = TRUE ) : array
리턴 array label => input

label() 공개 메소드

Return a single field label.
public label ( $field, array $attr = NULL ) : string
$attr array
리턴 string

load() 공개 메소드

Load a single record using the current data.
public load ( Database_Query_Builder_Select $query = NULL, $limit = 1 )
$query Database_Query_Builder_Select

loaded() 공개 메소드

Object data loaded status.
public loaded ( ) : boolean
리턴 boolean

pk() 공개 메소드

Returns the primary key of the model, optionally with a table name.
public pk ( $table = NULL ) : string
리턴 string

relate() 공개 메소드

Adds a relationship to the model
public relate ( $name, $value )

select_list() 공개 메소드

Get all of the records for this table as an associative array.
public select_list ( $key = NULL, $value = NULL ) : array
리턴 array key => value

state() 공개 메소드

Setting the model status can have side effects. Changing the state to "loaded" will merge the currently changed data with the original data. Changing to "new" will reset the original data to the default values. Setting a "deleted" state will reset the changed data. Possible model states: - new: record has not been created - deleted: record has been deleted - loaded: record has been loaded
public state ( $state = NULL ) : string
리턴 string when getting

table() 공개 메소드

Gets and sets the table name of the model.
public table ( $table = NULL ) : string
리턴 string table name

tk() 공개 메소드

Returns the title key of the model, optionally with a table name.
public tk ( $table = NULL ) : string
리턴 string

unrelate() 공개 메소드

Removes a relationship to the model
public unrelate ( $name, $value )

update() 공개 메소드

Update the current record using the current data.
public update ( )

values() 공개 메소드

Load all of the values in an associative array. Ignores all fields are not in the model.
public values ( array $values )
$values array

verbose() 공개 메소드

Return a single field value in verbose form.
public verbose ( $field ) : string
리턴 string

프로퍼티 상세

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

Changed object data
protected $_changed

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

database instance name
protected $_db

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

field list (name => object)
protected $_fields

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

Initialization status
protected $_init

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

model name
protected $_model

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

Original object data
protected $_original

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

primary key string or array (for composite keys)
protected $_primary_key

$_relations 보호되어 있는 정적으로 프로퍼티

Model many-to-many relations
protected static $_relations

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

default sorting parameters
protected $_sorting

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

Object state
protected $_state

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

database table name
protected $_table

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

title key string (for select lists)
protected $_title_key