PHP Class Granada\Granada

class Widget extends Model { }
Inheritance: implements ArrayAcces\ArrayAccess
Afficher le fichier Open project: surt/granada

Méthodes publiques

Свойство Type Description
$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 The ORM instance used by this model instance to communicate with the database.
$relating string The relationship type the model is currently resolving.
$relating_key string The foreign key of the "relating" relationship.
$relating_table string This is used during has_many_through eager loading.
$relationships array $relationships attributes will not be saved to the database, and are primarily used to hold relationships. __set and __get need the relationship method defined on the model to determine if the relationship exists.
$resultSetClass

Méthodes publiques

Méthode Description
__callStatic ( $method, $parameters ) Calls static methods directly on the Orm\Wrapper
__get ( $property ) Magic getter method, allows $model->property access to data.
__isset ( $property ) Magic isset method, allows isset($model->property) to work correctly.
__set ( $property, $value ) Magic setter method, allows $model->property = 'value' access to data.
as_array ( ) Wrapper for Idiorm's as_array method.
delete ( ) Delete the database row associated with this model instance.
factory ( $class_name, $connection_name = null ) Factory method used to acquire instances of the given class.
get ( $property ) Getter method, allows $model->get('property') access to data
get_resultSetClass ( )
hydrate ( $data ) Hydrate this model instance with an associative array of data.
id ( ) Get the database ID of this model instance.
is_dirty ( $property ) 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
list_dirty_fields ( ) Get the list of fields that need updating on next save
offsetExists ( integer | string $offset ) : boolean ArrayAccess
offsetGet ( integer | string $offset ) : mixed ArrayAccess
offsetSet ( integer | string $offset, mixed $value ) ArrayAccess
offsetUnset ( integer | string $offset ) ArrayAccess
save ( $ignore = false ) Save the data associated with this model instance to the database.
set ( $property, string | null $value = null ) Setter method, allows $model->set('property', 'value') access to data.
set_expr ( $property, string | null $value = null ) Setter method, allows $model->set_expr('property', 'value') access to data.
set_orm ( $orm ) Set the wrapped ORM instance associated with this Model instance.

Méthodes protégées

Méthode Description
_build_foreign_key_name ( $specified_foreign_key_name, $table_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.
_class_name_to_table_name ( $class_name ) Convert a namespace to the standard PEAR underscore format.
_get_id_column_name ( string $class_name ) Return the ID column name to use for this class. If it is not set on the class, returns null.
_get_static_property ( $class_name, string $property, $default = null ) 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 ) Static method to get a table name given a class name.
_has_one_or_many ( $associated_class_name, $foreign_key_name = null, $foreign_key_name_in_current_models_table = null, $connection_name = null ) 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.
belongs_to ( string $associated_class_name, string $foreign_key_name = null, $foreign_key_name_in_associated_models_table = null, $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, string $foreign_key_name = null, $foreign_key_name_in_current_models_table = null, $connection_name = null ) Helper method to manage one-to-many relations where the foreign key is on the associated table.
has_many_through ( string $associated_class_name, string $join_class_name = null, string $key_to_base_table = null, string $key_to_associated_table = null, $key_in_base_table = null, $key_in_associated_table = null, $connection_name = null ) 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, string $foreign_key_name = null, $foreign_key_name_in_current_models_table = null, $connection_name = null ) Helper method to manage one-to-one relations where the foreign key is on the associated table.

Method Details

__callStatic() public static méthode

Calls static methods directly on the Orm\Wrapper
public static __callStatic ( $method, $parameters )

__get() public méthode

Added: check for get_{property_name} method defined in model and not null missing_{property_name} method is null or undefined in model fetched relationships not loaded relationship. "lazy load" if method exists
public __get ( $property )

__isset() public méthode

Magic isset method, allows isset($model->property) to work correctly.
public __isset ( $property )

__set() public méthode

Added: use Model methods to determine if a relationship exists and populate it on $relationships instead of properties
public __set ( $property, $value )

_build_foreign_key_name() protected static méthode

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 ( $specified_foreign_key_name, $table_name )

_class_name_to_table_name() protected static méthode

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 ( $class_name )

_get_id_column_name() protected static méthode

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 )
$class_name string

_get_static_property() protected static méthode

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 ( $class_name, string $property, $default = null )
$property string

_get_table_name() protected static méthode

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.
protected static _get_table_name ( string $class_name )
$class_name string

_has_one_or_many() protected méthode

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 ( $associated_class_name, $foreign_key_name = null, $foreign_key_name_in_current_models_table = null, $connection_name = null )

as_array() public méthode

Wrapper for Idiorm's as_array method.
public as_array ( )

belongs_to() protected méthode

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, string $foreign_key_name = null, $foreign_key_name_in_associated_models_table = null, $connection_name = null )
$associated_class_name string
$foreign_key_name string

delete() public méthode

Delete the database row associated with this model instance.
public delete ( )

factory() public static méthode

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 ( $class_name, $connection_name = null )

get() public méthode

Getter method, allows $model->get('property') access to data
public get ( $property )

get_resultSetClass() public méthode

public get_resultSetClass ( )

has_many() protected méthode

Helper method to manage one-to-many relations where the foreign key is on the associated table.
protected has_many ( string $associated_class_name, string $foreign_key_name = null, $foreign_key_name_in_current_models_table = null, $connection_name = null )
$associated_class_name string
$foreign_key_name string

has_many_through() protected méthode

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, string $join_class_name = null, string $key_to_base_table = null, string $key_to_associated_table = null, $key_in_base_table = null, $key_in_associated_table = null, $connection_name = null )
$associated_class_name string
$join_class_name string
$key_to_base_table string
$key_to_associated_table string

has_one() protected méthode

Helper method to manage one-to-one relations where the foreign key is on the associated table.
protected has_one ( string $associated_class_name, string $foreign_key_name = null, $foreign_key_name_in_current_models_table = null, $connection_name = null )
$associated_class_name string
$foreign_key_name string

hydrate() public méthode

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 ( $data )

id() public méthode

Get the database ID of this model instance.
public id ( )

is_dirty() public méthode

Check whether the given field has changed since the object was created or saved
public is_dirty ( $property )

is_new() public méthode

Check whether the model was the result of a call to create() or not
public is_new ( ) : boolean
Résultat boolean

list_dirty_fields() public méthode

Get the list of fields that need updating on next save
public list_dirty_fields ( )

offsetExists() public méthode

ArrayAccess
public offsetExists ( integer | string $offset ) : boolean
$offset integer | string
Résultat boolean

offsetGet() public méthode

ArrayAccess
public offsetGet ( integer | string $offset ) : mixed
$offset integer | string
Résultat mixed

offsetSet() public méthode

ArrayAccess
public offsetSet ( integer | string $offset, mixed $value )
$offset integer | string
$value mixed

offsetUnset() public méthode

ArrayAccess
public offsetUnset ( integer | string $offset )
$offset integer | string

save() public méthode

Save the data associated with this model instance to the database.
public save ( $ignore = false )

set() public méthode

Setter method, allows $model->set('property', 'value') access to data.
public set ( $property, string | null $value = null )
$value string | null

set_expr() public méthode

Setter method, allows $model->set_expr('property', 'value') access to data.
public set_expr ( $property, string | null $value = null )
$value string | null

set_orm() public méthode

Set the wrapped ORM instance associated with this Model instance.
public set_orm ( $orm )

Property Details

$auto_prefix_models public_oe static_oe property

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
Résultat string

$orm public_oe property

The ORM instance used by this model instance to communicate with the database.
public $orm

$relating public_oe property

The relationship type the model is currently resolving.
public string $relating
Résultat string

$relating_key public_oe property

The foreign key of the "relating" relationship.
public string $relating_key
Résultat string

$relating_table public_oe property

This is used during has_many_through eager loading.
public string $relating_table
Résultat string

$relationships public_oe property

$relationships attributes will not be saved to the database, and are primarily used to hold relationships. __set and __get need the relationship method defined on the model to determine if the relationship exists.
public array $relationships
Résultat array

$resultSetClass public_oe static_oe property

public static $resultSetClass