PHP Интерфейс ManaPHP\Mvc\ModelInterface

Показать файл Открыть проект

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

Метод Описание
assign ( array $data, array $whiteList = null ) : static Assigns values to a model from an array $city->assign(['city_id'=>1,'city_name'=>'beijing']); $city->assign(['city_id'=>1,'city_name'=>'beijing'],['city_name']);
average ( string $column, string | array $parameters = null, integer | array $cacheOptions = null ) : double Allows to calculate the average value on a column matching the specified conditions
count ( string | array $parameters = null, string $column = '*', integer | array $cacheOptions = null ) : integer | array Allows to count how many records match the specified conditions
create ( array $data = null, array $whiteList = null ) : void Inserts a model instance. If the instance already exists in the persistence it will throw an exception Returning true on success or false otherwise.
delete ( ) : void Deletes a model instance. Returning true on success or false otherwise.
deleteAll ( string | array $conditions, array $bind = [] ) : integer
exists ( string | array $parameters = null, integer | array $cacheOptions = null ) : boolean
find ( string | array $parameters = null, integer | array $cacheOptions = null ) : static[] Allows to query a set of records that match the specified conditions
findAll ( string | array $parameters = null, integer | array $cacheOptions = null ) : static[] alias of find
findFirst ( string | array $parameters = null, integer | array $cacheOptions = null ) : static | false Allows to query the first record that match the specified conditions
getChangedFields ( ) : array Returns a list of changed values
getReadConnection ( ) : ManaPHP\DbInterface Gets internal database connection
getReadConnectionService ( ) : string Returns DependencyInjection connection service used to read data
getSnapshotData ( ) : array Returns the internal snapshot data
getSource ( ) : string Returns table name mapped in the model $city->getSource();
getWriteConnection ( ) : ManaPHP\DbInterface Gets internal database connection
getWriteConnectionService ( ) : string Returns DependencyInjection connection service used to write data
hasChanged ( string | array $fields ) : boolean Check if a specific attribute has changed This only works if the model is keeping data snapshots
max ( string $column, string | array $parameters = null, integer | array $cacheOptions = null ) : mixed Allows to get the max value of a column that match the specified conditions
min ( string $column, string | array $parameters = null, integer | array $cacheOptions = null ) : mixed Allows to get the min value of a column that match the specified conditions
query ( ManaPHP\DiInterface $dependencyInjector = null ) : ManaPHP\Mvc\Model\QueryBuilderInterface Create a criteria for a special model
save ( array $data = null, array $whiteList = null ) : void Inserts or updates a model instance. Returning true on success or false otherwise.
setConnectionService ( string $connectionService ) : static Sets both read/write connection services
setReadConnectionService ( string $connectionService ) : static Sets the DependencyInjection connection service used to read data
setWriteConnectionService ( string $connectionService ) : static Sets the DependencyInjection connection service used to write data
sum ( string $column, string | array $parameters = null, integer | array $cacheOptions = null ) : mixed Allows to calculate a summary on a column that match the specified conditions
toArray ( ) : array Returns the instance as an array representation
update ( array $data = null, array $whiteList = null ) : void Updates a model instance. If the instance does n't exist in the persistence it will throw an exception Returning true on success or false otherwise.
updateAll ( array $columnValues, string | array $conditions, array $bind = [] ) : integer

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

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

Assigns values to a model from an array $city->assign(['city_id'=>1,'city_name'=>'beijing']); $city->assign(['city_id'=>1,'city_name'=>'beijing'],['city_name']);
public assign ( array $data, array $whiteList = null ) : static
$data array
$whiteList array
Результат static

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

Allows to calculate the average value on a column matching the specified conditions
public static average ( string $column, string | array $parameters = null, integer | array $cacheOptions = null ) : double
$column string
$parameters string | array
$cacheOptions integer | array
Результат double

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

City::count(['country_id'=>2]);
public static count ( string | array $parameters = null, string $column = '*', integer | array $cacheOptions = null ) : integer | array
$parameters string | array
$column string
$cacheOptions integer | array
Результат integer | array

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

Inserts a model instance. If the instance already exists in the persistence it will throw an exception Returning true on success or false otherwise.
public create ( array $data = null, array $whiteList = null ) : void
$data array
$whiteList array
Результат void

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

Deletes a model instance. Returning true on success or false otherwise.
public delete ( ) : void
Результат void

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

public static deleteAll ( string | array $conditions, array $bind = [] ) : integer
$conditions string | array
$bind array
Результат integer

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

public static exists ( string | array $parameters = null, integer | array $cacheOptions = null ) : boolean
$parameters string | array
$cacheOptions integer | array
Результат boolean

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

$cities=City::find(['country_id'=>2]); $cities=City::find(['conditions'=>['country_id'=>2],'order'=>'city_id desc']); $cities=City::find([['country_id'=>2],'order'=>'city_id desc']); $cities=City::find(['conditions'=>'country_id =:country_id','bind'=>['country_id'=>2]]);
public static find ( string | array $parameters = null, integer | array $cacheOptions = null ) : static[]
$parameters string | array
$cacheOptions integer | array
Результат static[]

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

alias of find
public static findAll ( string | array $parameters = null, integer | array $cacheOptions = null ) : static[]
$parameters string | array
$cacheOptions integer | array
Результат static[]

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

$city=City::findFirst(10); $city=City::findFirst(['city_id'=>10]); $city=City::findFirst(['conditions'=>['city_id'=>10]]); $city=City::findFirst(['conditions'=>'city_id =:city_id','bind'=>['city_id'=>10]]);
public static findFirst ( string | array $parameters = null, integer | array $cacheOptions = null ) : static | false
$parameters string | array
$cacheOptions integer | array
Результат static | false

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

Returns a list of changed values
public getChangedFields ( ) : array
Результат array

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

Gets internal database connection
public getReadConnection ( ) : ManaPHP\DbInterface
Результат ManaPHP\DbInterface

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

Returns DependencyInjection connection service used to read data
public getReadConnectionService ( ) : string
Результат string

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

Returns the internal snapshot data
public getSnapshotData ( ) : array
Результат array

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

Returns table name mapped in the model $city->getSource();
public getSource ( ) : string
Результат string

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

Gets internal database connection
public getWriteConnection ( ) : ManaPHP\DbInterface
Результат ManaPHP\DbInterface

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

Returns DependencyInjection connection service used to write data
public getWriteConnectionService ( ) : string
Результат string

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

Check if a specific attribute has changed This only works if the model is keeping data snapshots
public hasChanged ( string | array $fields ) : boolean
$fields string | array
Результат boolean

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

Allows to get the max value of a column that match the specified conditions
public static max ( string $column, string | array $parameters = null, integer | array $cacheOptions = null ) : mixed
$column string
$parameters string | array
$cacheOptions integer | array
Результат mixed

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

Allows to get the min value of a column that match the specified conditions
public static min ( string $column, string | array $parameters = null, integer | array $cacheOptions = null ) : mixed
$column string
$parameters string | array
$cacheOptions integer | array
Результат mixed

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

Create a criteria for a special model
public static query ( ManaPHP\DiInterface $dependencyInjector = null ) : ManaPHP\Mvc\Model\QueryBuilderInterface
$dependencyInjector ManaPHP\DiInterface
Результат ManaPHP\Mvc\Model\QueryBuilderInterface

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

Inserts or updates a model instance. Returning true on success or false otherwise.
public save ( array $data = null, array $whiteList = null ) : void
$data array
$whiteList array
Результат void

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

Sets both read/write connection services
public setConnectionService ( string $connectionService ) : static
$connectionService string
Результат static

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

Sets the DependencyInjection connection service used to read data
public setReadConnectionService ( string $connectionService ) : static
$connectionService string
Результат static

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

Sets the DependencyInjection connection service used to write data
public setWriteConnectionService ( string $connectionService ) : static
$connectionService string
Результат static

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

Allows to calculate a summary on a column that match the specified conditions
public static sum ( string $column, string | array $parameters = null, integer | array $cacheOptions = null ) : mixed
$column string
$parameters string | array
$cacheOptions integer | array
Результат mixed

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

print_r($robot->toArray());
public toArray ( ) : array
Результат array

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

Updates a model instance. If the instance does n't exist in the persistence it will throw an exception Returning true on success or false otherwise.
public update ( array $data = null, array $whiteList = null ) : void
$data array
$whiteList array
Результат void

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

public static updateAll ( array $columnValues, string | array $conditions, array $bind = [] ) : integer
$columnValues array
$conditions string | array
$bind array
Результат integer