PHP Класс Granada\Orm\Wrapper

You shouldn't need to interact with this class directly. It is used internally by the Model base class.
Наследование: extends Granada\ORM
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$relationships

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

Свойство Тип Описание
$_class_name The wrapped find_one and find_many classes will return an instance or instances of this class.

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

Метод Описание
__call ( $method, $parameters ) Overrides __call to check for filter_$method names defined You can now define filters methods on the Granada Model as public static function filter_{filtermethodname} and call it from a static call ModelName::filtermethodname->.
assoc_to_keyval ( $assoc = null, boolean | string $key_field = null, boolean | string $val_field = null ) : array Converts a multi-dimensional associative array into an array of key => values with the provided field names
create ( $data = null ) Wrap Idiorm's create method to return an empty instance of the class associated with this wrapper instead of the raw ORM class.
filter ( ) Add a custom filter to the method chain specified on the model class. This allows custom queries to be added to models. The filter should take an instance of the ORM wrapper as its first argument and return an instance of the ORM wrapper. Any arguments passed to this method after the name of the filter will be passed to the called filter function as arguments after the ORM class.
find_many ( ) : array | Granada\ResultSet Tell the ORM that you are expecting multiple results from your query, and execute it. Will return an array of instances of the ORM class, or an empty array if no rows were returned.
find_one ( integer $id = null ) Wrap Idiorm's find_one method to return an instance of the class associated with this wrapper instead of the raw ORM class.
find_pairs ( $key = false, $value = false ) Added: Return pairs as result array('keyrecord_value'=>'valuerecord_value',.
for_table ( $table_name, $connection_name = parent::DEFAULT_CONNECTION ) Factory method, return an instance of this class bound to the supplied table name.
group_by_raw ( $expr ) Add an unquoted expression to the list of columns to GROUP BY
insert ( $rows, $ignore = false ) To create and save multiple elements, easy way Using an array with rows array(array('name'=>'value',.
order_by_raw ( $clause ) Add an unquoted expression as an ORDER BY clause
pluck ( string $column ) : mixed Pluck a single column from the result.
raw_join ( $join ) Create raw_join
reset_relation ( ) : Wrapper Added: Reset relation deletes the relationship "where" condition.
select_raw ( $expr, $alias = null ) Overload select_expr name
set_class_name ( string $class_name ) Set the name of the class which the wrapped methods should return instances of.
where_id_in ( $ids ) Special method to query the table by its primary key
with ( ) : Wrapper Added: Set the eagerly loaded models on the queryable model.

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

Метод Описание
_create_model_instance ( $orm ) Method to create an instance of the model class associated with this wrapper and populate it with the supplied Idiorm instance.
_get_instances ( array $rows ) : array Override Idiorm _instances_with_id_as_key Create instances of each row in the result and map them to an associative array with the primary IDs as the array keys.

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

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

.....
public __call ( $method, $parameters )

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

Method to create an instance of the model class associated with this wrapper and populate it with the supplied Idiorm instance.
protected _create_model_instance ( $orm )

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

Added: the array result key = primary key from the model Added: Eager loading of relationships defined "with()"
protected _get_instances ( array $rows ) : array
$rows array
Результат array

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

Converts a multi-dimensional associative array into an array of key => values with the provided field names
public static assoc_to_keyval ( $assoc = null, boolean | string $key_field = null, boolean | string $val_field = null ) : array
$key_field boolean | string
$val_field boolean | string
Результат array

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

Wrap Idiorm's create method to return an empty instance of the class associated with this wrapper instead of the raw ORM class.
public create ( $data = null )

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

Add a custom filter to the method chain specified on the model class. This allows custom queries to be added to models. The filter should take an instance of the ORM wrapper as its first argument and return an instance of the ORM wrapper. Any arguments passed to this method after the name of the filter will be passed to the called filter function as arguments after the ORM class.
public filter ( )

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

Tell the ORM that you are expecting multiple results from your query, and execute it. Will return an array of instances of the ORM class, or an empty array if no rows were returned.
public find_many ( ) : array | Granada\ResultSet
Результат array | Granada\ResultSet

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

Added: hidrate the model instance before returning
public find_one ( integer $id = null )
$id integer

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

....)
public find_pairs ( $key = false, $value = false )

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

A repeat of content in parent::for_table, so that created class is ORMWrapper, not ORM
public static for_table ( $table_name, $connection_name = parent::DEFAULT_CONNECTION )

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

Add an unquoted expression to the list of columns to GROUP BY
public group_by_raw ( $expr )

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

..), array('name2'=>'value2',...),..) or a array multiple
public insert ( $rows, $ignore = false )

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

Add an unquoted expression as an ORDER BY clause
public order_by_raw ( $clause )

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

Pluck a single column from the result.
public pluck ( string $column ) : mixed
$column string
Результат mixed

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

Create raw_join
public raw_join ( $join )

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

Added: Reset relation deletes the relationship "where" condition.
public reset_relation ( ) : Wrapper
Результат Wrapper

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

Overload select_expr name
public select_raw ( $expr, $alias = null )

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

Set the name of the class which the wrapped methods should return instances of.
public set_class_name ( string $class_name )
$class_name string

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

Special method to query the table by its primary key
public where_id_in ( $ids )

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

Added: Set the eagerly loaded models on the queryable model.
public with ( ) : Wrapper
Результат Wrapper

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

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

The wrapped find_one and find_many classes will return an instance or instances of this class.
protected $_class_name

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

public $relationships