PHP Класс Sprig_Core, sprig

Автор: Woody Gilk
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$_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