PHP Класс Model, paris

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

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

Свойство Тип Описание
$auto_prefix_models string Set a prefix for model names. This can be a namespace or any other abitrary prefix such as the PEAR naming convention.
$orm ORM The ORM instance used by this model instance to communicate with the database.
$short_table_names boolean Set true to to ignore namespace information when computing table names from class names.

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

Метод Описание
__call ( string $name, array $arguments ) : boolean | ORMWrapper Magic method to capture calls to undefined class methods.
__callStatic ( string $method, Array $parameters ) : Array Calls static methods directly on the ORMWrapper
__get ( string $property ) : null | string Magic getter method, allows $model->property access to data.
__isset ( string $property ) : boolean Magic isset method, allows isset($model->property) to work correctly.
__set ( string $property, string $value ) : void Magic setter method, allows $model->property = 'value' access to data.
__unset ( string $property ) : void Magic unset method, allows unset($model->property)
as_array ( ) : Array Wrapper for Idiorm's as_array method.
delete ( ) : null Delete the database row associated with this model instance.
factory ( string $class_name, null | string $connection_name = null ) : ORMWrapper Factory method used to acquire instances of the given class.
get ( string $property ) : string Getter method, allows $model->get('property') access to data
hydrate ( Array $data ) : void Hydrate this model instance with an associative array of data.
id ( ) : integer Get the database ID of this model instance.
is_dirty ( string $property ) : boolean Check whether the given field has changed since the object was created or saved
is_new ( ) : boolean Check whether the model was the result of a call to create() or not
save ( ) : null Save the data associated with this model instance to the database.
set ( string | array $property, string | null $value = null ) : Model Setter method, allows $model->set('property', 'value') access to data.
set_expr ( string | array $property, string | null $value = null ) : Model Setter method, allows $model->set_expr('property', 'value') access to data.
set_orm ( ORM $orm ) : void Set the wrapped ORM instance associated with this Model instance.

Защищенные методы

Метод Описание
_build_foreign_key_name ( string $specified_foreign_key_name, string $table_name ) : string Build a foreign key based on a table name. If the first argument (the specified foreign key column name) is null, returns the second argument (the name of the table) with the default foreign key column suffix appended.
_class_name_to_table_name ( string $class_name ) : string Convert a namespace to the standard PEAR underscore format.
_get_id_column_name ( string $class_name ) : string | null Return the ID column name to use for this class. If it is not set on the class, returns null.
_get_static_property ( string $class_name, string $property, null | string $default = null ) : string Retrieve the value of a static property on a class. If the class or the property does not exist, returns the default value supplied as the third argument (which defaults to null).
_get_table_name ( string $class_name ) : string Static method to get a table name given a class name.
_has_one_or_many ( string $associated_class_name, null | string $foreign_key_name = null, null | string $foreign_key_name_in_current_models_table = null, null | string $connection_name = null ) : ORMWrapper Internal method to construct the queries for both the has_one and has_many methods. These two types of association are identical; the only difference is whether find_one or find_many is used to complete the method chain.
_use_short_table_name ( string $class_name ) : boolean Should short table names, disregarding class namespaces, be computed?
belongs_to ( string $associated_class_name, null | string $foreign_key_name = null, null | string $foreign_key_name_in_associated_models_table = null, null | string $connection_name = null ) Helper method to manage one-to-one and one-to-many relations where the foreign key is on the base table.
has_many ( string $associated_class_name, null | string $foreign_key_name = null, null | string $foreign_key_name_in_current_models_table = null, null | string $connection_name = null ) : ORMWrapper Helper method to manage one-to-many relations where the foreign key is on the associated table.
has_many_through ( string $associated_class_name, null | string $join_class_name = null, null | string $key_to_base_table = null, null | string $key_to_associated_table = null, null | string $key_in_base_table = null, null | string $key_in_associated_table = null, null | string $connection_name = null ) : ORMWrapper Helper method to manage many-to-many relationships via an intermediate model. See README for a full explanation of the parameters.
has_one ( string $associated_class_name, null | string $foreign_key_name = null, null | string $foreign_key_name_in_current_models_table = null, null | string $connection_name = null ) : ORMWrapper Helper method to manage one-to-one relations where the foreign key is on the associated table.

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

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

In this case we are attempting to convert camel case formatted methods into underscore formatted methods. This allows us to call methods using camel case and remain backwards compatible.
public __call ( string $name, array $arguments ) : boolean | ORMWrapper
$name string
$arguments array
Результат boolean | ORMWrapper

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

Calls static methods directly on the ORMWrapper
public static __callStatic ( string $method, Array $parameters ) : Array
$method string
$parameters Array
Результат Array

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

Magic getter method, allows $model->property access to data.
public __get ( string $property ) : null | string
$property string
Результат null | string

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

Magic isset method, allows isset($model->property) to work correctly.
public __isset ( string $property ) : boolean
$property string
Результат boolean

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

Magic setter method, allows $model->property = 'value' access to data.
public __set ( string $property, string $value ) : void
$property string
$value string
Результат void

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

Magic unset method, allows unset($model->property)
public __unset ( string $property ) : void
$property string
Результат void

_build_foreign_key_name() защищенный статический Метод

Build a foreign key based on a table name. If the first argument (the specified foreign key column name) is null, returns the second argument (the name of the table) with the default foreign key column suffix appended.
protected static _build_foreign_key_name ( string $specified_foreign_key_name, string $table_name ) : string
$specified_foreign_key_name string
$table_name string
Результат string

_class_name_to_table_name() защищенный статический Метод

Then convert a class name in CapWords to a table name in lowercase_with_underscores. Finally strip doubled up underscores For example, CarTyre would be converted to car_tyre. And Project\Models\CarTyre would be project_models_car_tyre.
protected static _class_name_to_table_name ( string $class_name ) : string
$class_name string
Результат string

_get_id_column_name() защищенный статический Метод

Return the ID column name to use for this class. If it is not set on the class, returns null.
protected static _get_id_column_name ( string $class_name ) : string | null
$class_name string
Результат string | null

_get_static_property() защищенный статический Метод

Retrieve the value of a static property on a class. If the class or the property does not exist, returns the default value supplied as the third argument (which defaults to null).
protected static _get_static_property ( string $class_name, string $property, null | string $default = null ) : string
$class_name string
$property string
$default null | string
Результат string

_get_table_name() защищенный статический Метод

If the supplied class has a public static property named $_table, the value of this property will be returned. If not, the class name will be converted using the _class_name_to_table_name method method. If Model::$short_table_names == true or public static property $_table_use_short_name == true then $class_name passed to _class_name_to_table_name is stripped of namespace information.
protected static _get_table_name ( string $class_name ) : string
$class_name string
Результат string

_has_one_or_many() защищенный Метод

Internal method to construct the queries for both the has_one and has_many methods. These two types of association are identical; the only difference is whether find_one or find_many is used to complete the method chain.
protected _has_one_or_many ( string $associated_class_name, null | string $foreign_key_name = null, null | string $foreign_key_name_in_current_models_table = null, null | string $connection_name = null ) : ORMWrapper
$associated_class_name string
$foreign_key_name null | string
$foreign_key_name_in_current_models_table null | string
$connection_name null | string
Результат ORMWrapper

_use_short_table_name() защищенный статический Метод

$class_property overrides $global_option, unless $class_property is null
protected static _use_short_table_name ( string $class_name ) : boolean
$class_name string
Результат boolean

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

Wrapper for Idiorm's as_array method.
public as_array ( ) : Array
Результат Array

belongs_to() защищенный Метод

Helper method to manage one-to-one and one-to-many relations where the foreign key is on the base table.
protected belongs_to ( string $associated_class_name, null | string $foreign_key_name = null, null | string $foreign_key_name_in_associated_models_table = null, null | string $connection_name = null )
$associated_class_name string
$foreign_key_name null | string
$foreign_key_name_in_associated_models_table null | string
$connection_name null | string

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

Delete the database row associated with this model instance.
public delete ( ) : null
Результат null

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

The class name should be supplied as a string, and the class should already have been loaded by PHP (or a suitable autoloader should exist). This method actually returns a wrapped ORM object which allows a database query to be built. The wrapped ORM object is responsible for returning instances of the correct class when its find_one or find_many methods are called.
public static factory ( string $class_name, null | string $connection_name = null ) : ORMWrapper
$class_name string
$connection_name null | string
Результат ORMWrapper

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

Getter method, allows $model->get('property') access to data
public get ( string $property ) : string
$property string
Результат string

has_many() защищенный Метод

Helper method to manage one-to-many relations where the foreign key is on the associated table.
protected has_many ( string $associated_class_name, null | string $foreign_key_name = null, null | string $foreign_key_name_in_current_models_table = null, null | string $connection_name = null ) : ORMWrapper
$associated_class_name string
$foreign_key_name null | string
$foreign_key_name_in_current_models_table null | string
$connection_name null | string
Результат ORMWrapper

has_many_through() защищенный Метод

Helper method to manage many-to-many relationships via an intermediate model. See README for a full explanation of the parameters.
protected has_many_through ( string $associated_class_name, null | string $join_class_name = null, null | string $key_to_base_table = null, null | string $key_to_associated_table = null, null | string $key_in_base_table = null, null | string $key_in_associated_table = null, null | string $connection_name = null ) : ORMWrapper
$associated_class_name string
$join_class_name null | string
$key_to_base_table null | string
$key_to_associated_table null | string
$key_in_base_table null | string
$key_in_associated_table null | string
$connection_name null | string
Результат ORMWrapper

has_one() защищенный Метод

Helper method to manage one-to-one relations where the foreign key is on the associated table.
protected has_one ( string $associated_class_name, null | string $foreign_key_name = null, null | string $foreign_key_name_in_current_models_table = null, null | string $connection_name = null ) : ORMWrapper
$associated_class_name string
$foreign_key_name null | string
$foreign_key_name_in_current_models_table null | string
$connection_name null | string
Результат ORMWrapper

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

WARNING: The keys in the array MUST match with columns in the corresponding database table. If any keys are supplied which do not match up with columns, the database will throw an error.
public hydrate ( Array $data ) : void
$data Array
Результат void

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

Get the database ID of this model instance.
public id ( ) : integer
Результат integer

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

Check whether the given field has changed since the object was created or saved
public is_dirty ( string $property ) : boolean
$property string
Результат boolean

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

Check whether the model was the result of a call to create() or not
public is_new ( ) : boolean
Результат boolean

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

Save the data associated with this model instance to the database.
public save ( ) : null
Результат null

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

Setter method, allows $model->set('property', 'value') access to data.
public set ( string | array $property, string | null $value = null ) : Model
$property string | array
$value string | null
Результат Model

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

Setter method, allows $model->set_expr('property', 'value') access to data.
public set_expr ( string | array $property, string | null $value = null ) : Model
$property string | array
$value string | null
Результат Model

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

Set the wrapped ORM instance associated with this Model instance.
public set_orm ( ORM $orm ) : void
$orm ORM
Результат void

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

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

Set a prefix for model names. This can be a namespace or any other abitrary prefix such as the PEAR naming convention.
public static string $auto_prefix_models
Результат string

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

The ORM instance used by this model instance to communicate with the database.
public ORM $orm
Результат ORM

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

Set true to to ignore namespace information when computing table names from class names.
public static bool $short_table_names
Результат boolean