PHP Class Bluz\Db\Row

Example of Users\Row namespace Application\Users; class Row extends \Bluz\Db\Row { public function beforeInsert() { $this->created = gmdate('Y-m-d H:i:s'); } public function beforeUpdate() { $this->updated = gmdate('Y-m-d H:i:s'); } } $userRow = new \Application\Users\Row(); $userRow -> login = 'username'; $userRow -> save();
Author: Anton Shevchuk
Inheritance: implements JsonSerializable, implements ArrayAccess, use trait Bluz\Common\Container\Container, use trait Bluz\Common\Container\ArrayAccess, use trait Bluz\Common\Container\JsonSerialize, use trait Bluz\Common\Container\MagicAccess
Afficher le fichier Open project: bluzphp/framework Class Usage Examples

Protected Properties

Свойство Type Description
$clean array This is set to a copy of $data when the data is fetched from a database, specified as a new tuple in the constructor, or when dirty data is posted to the database with save().
$relations relations rows
$table instance of Table class
$tableClass name of Table class

Méthodes publiques

Méthode Description
__construct ( array $data = [] ) Create Row instance
__debugInfo ( ) : array Magic method for var_dump()
__sleep ( ) : string[] List of required for serialization properties
__toString ( ) : string Cast to string as class name
assert ( array | object $data ) : boolean Assert input data
delete ( ) : integer Delete existing row
getRelation ( string $modelName ) : Row | false Get relation by model name
getRelations ( string $modelName ) : array Get relations by model name
getTable ( ) : Table Returns the table object, or null if this is disconnected row
refresh ( ) : void Refreshes properties from the database
save ( ) : mixed Saves the properties to the database.
setRelation ( Row $row ) : Row Set relation
setTable ( Table $table ) : self Setup Table instance
validate ( array | object $data ) : boolean Validate input data

Méthodes protégées

Méthode Description
afterDelete ( ) : void Allows post-delete logic to be applied to row.
afterInsert ( ) : void Allows post-insert logic to be applied to row.
afterRead ( ) : void After read data from Db
afterSave ( ) : void Allows post-insert and post-update logic to be applied to row.
afterUpdate ( ) : void Allows post-update logic to be applied to row.
beforeDelete ( ) : void Allows pre-delete logic to be applied to row.
beforeInsert ( ) : void Allows pre-insert logic to be applied to row.
beforeSave ( ) : void Allows pre-insert and pre-update logic to be applied to row.
beforeUpdate ( ) : void Allows pre-update logic to be applied to row.
doInsert ( ) : mixed Insert row to Db
doUpdate ( ) : integer Update row
getPrimaryKey ( ) : array Retrieves an associative array of primary keys, if it exists

Method Details

__construct() public méthode

Create Row instance
public __construct ( array $data = [] )
$data array

__debugInfo() public méthode

Magic method for var_dump()
See also: var_dump()
public __debugInfo ( ) : array
Résultat array

__sleep() public méthode

List of required for serialization properties
public __sleep ( ) : string[]
Résultat string[]

__toString() public méthode

Cast to string as class name
public __toString ( ) : string
Résultat string

afterDelete() protected méthode

Subclasses may override this method
protected afterDelete ( ) : void
Résultat void

afterInsert() protected méthode

Subclasses may override this method
protected afterInsert ( ) : void
Résultat void

afterRead() protected méthode

After read data from Db
protected afterRead ( ) : void
Résultat void

afterSave() protected méthode

Subclasses may override this method
protected afterSave ( ) : void
Résultat void

afterUpdate() protected méthode

Subclasses may override this method
protected afterUpdate ( ) : void
Résultat void

assert() public méthode

Assert input data
public assert ( array | object $data ) : boolean
$data array | object
Résultat boolean

beforeDelete() protected méthode

Subclasses may override this method
protected beforeDelete ( ) : void
Résultat void

beforeInsert() protected méthode

Subclasses may override this method
protected beforeInsert ( ) : void
Résultat void

beforeSave() protected méthode

Subclasses may override this method
protected beforeSave ( ) : void
Résultat void

beforeUpdate() protected méthode

Subclasses may override this method
protected beforeUpdate ( ) : void
Résultat void

delete() public méthode

Delete existing row
public delete ( ) : integer
Résultat integer The number of deleted rows

doInsert() protected méthode

Insert row to Db
protected doInsert ( ) : mixed
Résultat mixed The primary key value(s), as an associative array if the key is compound, or a scalar if the key is single-column

doUpdate() protected méthode

Update row
protected doUpdate ( ) : integer
Résultat integer The number of rows updated

getPrimaryKey() protected méthode

Retrieves an associative array of primary keys, if it exists
protected getPrimaryKey ( ) : array
Résultat array

getRelation() public méthode

Get relation by model name
public getRelation ( string $modelName ) : Row | false
$modelName string
Résultat Row | false

getRelations() public méthode

Get relations by model name
public getRelations ( string $modelName ) : array
$modelName string
Résultat array

getTable() public méthode

Returns the table object, or null if this is disconnected row
public getTable ( ) : Table
Résultat Table

refresh() public méthode

Refreshes properties from the database
public refresh ( ) : void
Résultat void

save() public méthode

This performs an intelligent insert/update, and reloads the properties with fresh data from the table on success.
public save ( ) : mixed
Résultat mixed The primary key value(s), as an associative array if the key is compound, or a scalar if the key is single-column

setRelation() public méthode

Set relation
public setRelation ( Row $row ) : Row
$row Row
Résultat Row

setTable() public méthode

Setup Table instance
public setTable ( Table $table ) : self
$table Table
Résultat self

validate() public méthode

Validate input data
public validate ( array | object $data ) : boolean
$data array | object
Résultat boolean

Property Details

$clean protected_oe property

This is set to a copy of $data when the data is fetched from a database, specified as a new tuple in the constructor, or when dirty data is posted to the database with save().
protected array $clean
Résultat array

$relations protected_oe property

relations rows
protected $relations

$table protected_oe property

instance of Table class
protected $table

$tableClass protected_oe property

name of Table class
protected $tableClass