PHP Class Ouzo\Model

Inheritance: extends Validatable
Show file Open project: letsdrink/ouzo Class Usage Examples

Public Methods

Method Description
__construct ( array $params ) Creates a new model object.
__get ( $name )
__isset ( $name )
__set ( $name, $value )
__toString ( )
__unset ( $name )
_callAfterSaveCallbacks ( )
_callBeforeSaveCallbacks ( )
_getFields ( )
_resetModifiedFields ( )
alias ( $alias )
all ( ) : Model[]
assignAttributes ( $attributes )
attributes ( )
count ( $where = '', $bindValues = null )
create ( array $attributes = [] ) : static
createWithoutValidation ( array $attributes = [] ) : static Should be used for tests purposes only.
definedAttributes ( )
delete ( )
find ( $where, $whereValues, array $orderBy = [], integer $limit = null, integer $offset = null ) : Model[]
findById ( $value ) : static
findByIdOrNull ( $value ) : static
findBySql ( $nativeSql, array $params = [] ) : Model[] Executes a native sql and returns an array of model objects created by passing every result row to the model constructor.
get ( $names, $default = null )
getFields ( )
getFieldsWithoutPrimaryKey ( )
getId ( )
getIdName ( )
getModelName ( )
getRelation ( $name ) : Relation
getSequenceName ( )
getTableName ( )
innerJoin ( $relation, null $alias = null, array $on = [] ) : ModelQueryBuilder
insert ( )
insertOrUpdate ( )
inspect ( ) Returns model object as a nicely formatted string.
isNew ( )
join ( $relation, null $alias = null, string $type = 'LEFT', array $on = [] ) : ModelQueryBuilder
metaInstance ( ) : static
newInstance ( array $attributes ) : static
nullifyIfEmpty ( )
queryBuilder ( null $alias = null ) : ModelQueryBuilder
reload ( ) : static
rightJoin ( $relation, null $alias = null, array $on = [] ) : ModelQueryBuilder
select ( $columns, integer $type = PDO::FETCH_NUM ) : ModelQueryBuilder
selectDistinct ( $columns, integer $type = PDO::FETCH_NUM ) : ModelQueryBuilder
update ( )
updateAttributes ( $attributes )
using ( $relation, null $alias = null ) : ModelQueryBuilder
where ( string $params = '', array $values = [] ) : ModelQueryBuilder

Private Methods

Method Description
_callCallbacks ( $callbacks )
_fetchRelation ( $name )
_findById ( $value )
_findByIdOrNull ( $value )
_getFieldsWithoutPrimaryKey ( )
_prepareParameters ( array &$params )
filterAttributes ( $data )
filterAttributesPreserveNull ( $data )
getAttributesForUpdate ( )

Method Details

__construct() public method

Accepted parameters:
public __construct ( array $params )
$params array {

__get() public method

public __get ( $name )

__isset() public method

public __isset ( $name )

__set() public method

public __set ( $name, $value )

__toString() public method

public __toString ( )

__unset() public method

public __unset ( $name )

_callAfterSaveCallbacks() public method

_callBeforeSaveCallbacks() public method

_getFields() public method

public _getFields ( )

_resetModifiedFields() public method

alias() public static method

public static alias ( $alias )

all() public static method

public static all ( ) : Model[]
return Model[]

assignAttributes() public method

public assignAttributes ( $attributes )

attributes() public method

public attributes ( )

count() public static method

public static count ( $where = '', $bindValues = null )

create() public static method

public static create ( array $attributes = [] ) : static
$attributes array
return static

createWithoutValidation() public static method

Should be used for tests purposes only.
public static createWithoutValidation ( array $attributes = [] ) : static
$attributes array
return static

definedAttributes() public method

public definedAttributes ( )

delete() public method

public delete ( )

find() public static method

public static find ( $where, $whereValues, array $orderBy = [], integer $limit = null, integer $offset = null ) : Model[]
$where
$whereValues
$orderBy array
$limit integer
$offset integer
return Model[]

findById() public static method

public static findById ( $value ) : static
$value
return static

findByIdOrNull() public static method

public static findByIdOrNull ( $value ) : static
$value
return static

findBySql() public static method

Executes a native sql and returns an array of model objects created by passing every result row to the model constructor.
public static findBySql ( $nativeSql, array $params = [] ) : Model[]
$nativeSql - database specific sql
$params array - bind parameters
return Model[]

get() public method

public get ( $names, $default = null )

getFields() public static method

public static getFields ( )

getFieldsWithoutPrimaryKey() public static method

public static getFieldsWithoutPrimaryKey ( )

getId() public method

public getId ( )

getIdName() public method

public getIdName ( )

getModelName() public method

public getModelName ( )

getRelation() public method

public getRelation ( $name ) : Relation
$name
return Ouzo\Db\Relation

getSequenceName() public method

public getSequenceName ( )

getTableName() public method

public getTableName ( )

innerJoin() public static method

public static innerJoin ( $relation, null $alias = null, array $on = [] ) : ModelQueryBuilder
$relation
$alias null
$on array
return Ouzo\Db\ModelQueryBuilder

insert() public method

public insert ( )

insertOrUpdate() public method

public insertOrUpdate ( )

inspect() public method

Returns model object as a nicely formatted string.
public inspect ( )

isNew() public method

public isNew ( )

join() public static method

public static join ( $relation, null $alias = null, string $type = 'LEFT', array $on = [] ) : ModelQueryBuilder
$relation
$alias null
$type string
$on array
return Ouzo\Db\ModelQueryBuilder

metaInstance() public static method

public static metaInstance ( ) : static
return static

newInstance() public static method

public static newInstance ( array $attributes ) : static
$attributes array
return static

nullifyIfEmpty() public method

public nullifyIfEmpty ( )

queryBuilder() public static method

public static queryBuilder ( null $alias = null ) : ModelQueryBuilder
$alias null
return Ouzo\Db\ModelQueryBuilder

reload() public method

public reload ( ) : static
return static

rightJoin() public static method

public static rightJoin ( $relation, null $alias = null, array $on = [] ) : ModelQueryBuilder
$relation
$alias null
$on array
return Ouzo\Db\ModelQueryBuilder

select() public static method

public static select ( $columns, integer $type = PDO::FETCH_NUM ) : ModelQueryBuilder
$columns
$type integer
return Ouzo\Db\ModelQueryBuilder

selectDistinct() public static method

public static selectDistinct ( $columns, integer $type = PDO::FETCH_NUM ) : ModelQueryBuilder
$columns
$type integer
return Ouzo\Db\ModelQueryBuilder

update() public method

public update ( )

updateAttributes() public method

public updateAttributes ( $attributes )

using() public static method

public static using ( $relation, null $alias = null ) : ModelQueryBuilder
$relation
$alias null
return Ouzo\Db\ModelQueryBuilder

where() public static method

public static where ( string $params = '', array $values = [] ) : ModelQueryBuilder
$params string
$values array
return Ouzo\Db\ModelQueryBuilder