PHP Класс mtv\models\Model

You can access the fields on a model object in the following ways: $post->field_name; $post->attributes['field_name']; If you need an array of the fields on a model object, do this: $data = $post->attributes;
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$attributes Where the model's data is stored
$cache_groups WP Object Cache groups this model is associated with
$collection
$defaults Default model data used when a new model is created
$editable_json_fields Attributes that can be updated over the wire
$json_fields Attributes that are OK to send over the wire

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

Свойство Тип Описание
$_previous_attributes Attributes that have been changed since the last save or fetch
$_synchronized Is this model's data sync'd with the DB?

Открытые методы

Метод Описание
__construct ( $args = [] )
__get ( $name )
__isset ( $name )
__set ( $name, $val )
__toString ( )
__unset ( $name )
clear ( ) Delete all the attributes in this model
fetch ( ) Populate this model from permanent storage
from_json ( &$data ) Create a new model from json data sent over the wire
initialize ( $args ) Call initialize when the model is created
parse ( &$data ) Process the raw data from permanent storage
reload ( &$data ) Update this model with data from permanent storage
save ( ) Write the data in this model to permanent storage
set ( $args, $fetching = false ) Set a bunch of attributes at once
set_from_json ( &$data ) Update this model from json data sent over the wire
to_json ( ) Returns an assoc array of this model's data to send over the wire
validate ( ) Validate the data in this model
values ( ) Returns an array of selected values TODO: Return all values if no params are given

Описание методов

__construct() публичный Метод

public __construct ( $args = [] )

__get() публичный Метод

public __get ( $name )

__isset() публичный Метод

public __isset ( $name )

__set() публичный Метод

public __set ( $name, $val )

__toString() публичный Метод

public __toString ( )

__unset() публичный Метод

public __unset ( $name )

clear() публичный Метод

Delete all the attributes in this model
public clear ( )

fetch() публичный Метод

Populate this model from permanent storage
public fetch ( )

from_json() публичный статический Метод

Create a new model from json data sent over the wire
public static from_json ( &$data )

initialize() публичный Метод

Call initialize when the model is created
public initialize ( $args )

parse() публичный Метод

Process the raw data from permanent storage
public parse ( &$data )

reload() публичный Метод

Update this model with data from permanent storage
public reload ( &$data )

save() публичный Метод

Write the data in this model to permanent storage
public save ( )

set() публичный Метод

Set a bunch of attributes at once
public set ( $args, $fetching = false )

set_from_json() публичный Метод

Update this model from json data sent over the wire
public set_from_json ( &$data )

to_json() публичный Метод

Returns an assoc array of this model's data to send over the wire
public to_json ( )

validate() публичный Метод

Validate the data in this model
public validate ( )

values() публичный Метод

Returns an array of selected values TODO: Return all values if no params are given
public values ( )

Описание свойств

$_previous_attributes защищенное свойство

Attributes that have been changed since the last save or fetch
protected $_previous_attributes

$_synchronized защищенное свойство

Is this model's data sync'd with the DB?
protected $_synchronized

$attributes публичное свойство

Where the model's data is stored
public $attributes

$cache_groups публичное свойство

WP Object Cache groups this model is associated with
public $cache_groups

$collection публичное статическое свойство

public static $collection

$defaults публичное свойство

Default model data used when a new model is created
public $defaults

$editable_json_fields публичное свойство

Attributes that can be updated over the wire
public $editable_json_fields

$json_fields публичное свойство

Attributes that are OK to send over the wire
public $json_fields