PHP Class Scalr\Model\AbstractEntity

Since: 4.5.0 (10.10.2013)
Author: Vitaliy Demidov ([email protected])
Inheritance: extends Scalr\Model\AbstractGetter, implements IteratorAggregat\IteratorAggregate
Show file Open project: scalr/scalr Class Usage Examples

Public Methods

Method Description
__call ( $method, $args )
__callStatic ( $name, $arguments )
__get ( $prop )
__set ( $prop, $value )
__unset ( $prop )
_buildQuery ( array $criteria, string $conjunction = 'AND', string $tableAlias = null ) : array Builds query statement
db ( ) : ADODB_mysqli Gets database instance associated with the entity
delete ( ) Removes current record from database by primary key
fields ( string $tableAlias = null, boolean $prefixed = false ) : string Gets comma separated list of the columns prefixed either with the table name or the specified table alias
getEntityAnnotation ( ) : Scalr\Model\Loader\Entity Gets entity annotation for the class
getIterator ( ) : Scalr\Model\EntityPropertiesIterator
load ( array | object $obj, string $tableAlias = null ) Loads an entity from array or object
qstr ( string | Scalr\Model\Loader\Field $field, mixed $value = null ) : string Escapes value for the field
result ( integer $resultType ) : AbstractEntity Instantiate an object and sets the type of the result
save ( ) Saves current entity to database
table ( string $alias = null ) : string Gets table name which is associated with the entity
type ( string $field ) : Scalr\Model\Type\TypeInterface Gets the type for the specified field
update ( array | Iterato\Iterator $fieldValues ) Updates only specified properties to database ingoring all others

Private Methods

Method Description
_column ( string $fieldName, string $tableAlias = null, string $alias = null ) : string Gets column name for the specified field
_delete ( array $criteria = null, integer $limit = null ) : integer Removes records from database by criteria
_deletePk ( array $args = [] ) : integer Removes record from database by primary key
_fetchIndexes ( ) Retrieves show indexes info and stores it in the cache
_find ( array $criteria = null, array $group = null, array $order = null, integer $limit = null, integer $offset = null, boolean $countRecords = null ) : ArrayCollection | EntityIterator | ADORecordSet_mysql\ADORecordSet_mysqli Finds collection of the values by any key
_findOne ( array $criteria = null, array $group = null, array $order = null ) : AbstractEntity | null Finds one record by given criteria
_findPk ( array $args = [] ) : AbstractEntity | null Finds record by primary key
_hasUniqueIndex ( ) : boolean Checks whether the table has at least one unique index
_parseClassDocComment ( ) Parses phpdoc comment for entity class
_prepareSaveStatement ( ) : Scalr\Model\EntityStatement Prepares statement to store data in database

Method Details

__call() public method

public __call ( $method, $args )

__callStatic() public static method

public static __callStatic ( $name, $arguments )

__get() public method

public __get ( $prop )

__set() public method

public __set ( $prop, $value )

__unset() public method

public __unset ( $prop )

_buildQuery() public method

Builds query statement
public _buildQuery ( array $criteria, string $conjunction = 'AND', string $tableAlias = null ) : array
$criteria array Criteria array
$conjunction string optional Conjucntion
$tableAlias string optional Table alias
return array

db() public method

Gets database instance associated with the entity
public db ( ) : ADODB_mysqli
return ADODB_mysqli Database connection instance

delete() public method

Removes current record from database by primary key
public delete ( )

fields() public method

Gets comma separated list of the columns prefixed either with the table name or the specified table alias
public fields ( string $tableAlias = null, boolean $prefixed = false ) : string
$tableAlias string optional An table alias
$prefixed boolean optional Should the column names be provided with alias prefixed by the tableAlias
return string Returns comma separated list of the columns

getEntityAnnotation() public method

Gets entity annotation for the class
public getEntityAnnotation ( ) : Scalr\Model\Loader\Entity
return Scalr\Model\Loader\Entity Returns entity annotation for the class

getIterator() public method

See also: IteratorAggregate::getIterator()
public getIterator ( ) : Scalr\Model\EntityPropertiesIterator
return Scalr\Model\EntityPropertiesIterator Gets EntityPropertiesIterator

load() public method

Loads an entity from array or object
public load ( array | object $obj, string $tableAlias = null )
$obj array | object Source data
$tableAlias string optional The table alias which should be threated as column name prefix

qstr() public method

Escapes value for the field
public qstr ( string | Scalr\Model\Loader\Field $field, mixed $value = null ) : string
$field string | Scalr\Model\Loader\Field The name of the field or the Field object
$value mixed optional The value to escape or it will take field's value from the object
return string Returns escaped value for the fiel

result() public static method

Instantiate an object and sets the type of the result
public static result ( integer $resultType ) : AbstractEntity
$resultType integer The type of the result
return AbstractEntity

save() public method

Saves current entity to database
public save ( )

table() public method

Gets table name which is associated with the entity
public table ( string $alias = null ) : string
$alias string optional The table alias
return string The name of the database table

type() public method

Alias of the $entity->getIterator()->getField('name')->type;
public type ( string $field ) : Scalr\Model\Type\TypeInterface
$field string The name of the field
return Scalr\Model\Type\TypeInterface Returns field's type

update() public method

It also stores field's values in the object itself.
public update ( array | Iterato\Iterator $fieldValues )
$fieldValues array | Iterato\Iterator The list of the fields with its values looks like [fieldName1 => $value1, filedName2 ...] If it is provided with the field name in the value place with numerical index it will update the record with the value taken from the entity itself.