PHP 클래스 Model, paris

저자: ndusan
파일 보기 프로젝트 열기: j4mie/paris 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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