Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
AbstractRepository Class Reference

A repository for managing CRUD operations on a model. More...

+ Inheritance diagram for AbstractRepository:

Public Member Functions

 all (string $condition='', $included=false, array $parameters=[], bool $useCache=false)
 Load all instances.
 
 orderBy (string $field, string $order='ASC', string $condition='', $included=false, array $parameters=[], bool $useCache=false)
 Load all instances with order.
 
 byId ($keyValues, $included=true, bool $useCache=false)
 Load one instance by id.
 
 one (string $condition='', $included=true, array $parameters=[], bool $useCache=false)
 Load one instance.
 
 insert (object $instance, bool $insertMany=false)
 Insert a new instance $instance into the database.
 
 update (object $instance, bool $insertMany=false)
 Update an instance $instance in the database.
 
 save (object $instance, bool $insertMany=false)
 Save (insert or update) an instance $instance in the database.
 
 remove (object $instance)
 Remove an instance $instance from the database.
 
 count (string $condition='',?array $parameters=null)
 Returns the number of instances.
 

Protected Member Functions

 getModel ()
 

Detailed Description

A repository for managing CRUD operations on a model.

Ubiquity\orm\repositories$AbstractRepository This class is part of Ubiquity

Author
jc
Version
1.0.3

Definition at line 18 of file AbstractRepository.php.

Member Function Documentation

◆ all()

all ( string  $condition = '',
  $included = false,
array  $parameters = [ ],
bool  $useCache = false 
)

Load all instances.

Parameters
string$condition
array | boolean$included
array$parameters
bool$useCache
Returns
array

Definition at line 31 of file AbstractRepository.php.

◆ byId()

byId (   $keyValues,
  $included = true,
bool  $useCache = false 
)

Load one instance by id.

Parameters
$keyValues
bool | array$included
bool$useCache
Returns
?object

Definition at line 58 of file AbstractRepository.php.

◆ count()

count ( string  $condition = '',
?array  $parameters = null 
)

Returns the number of instances.

Parameters
string$condition
array$parameters
Returns
int

Definition at line 127 of file AbstractRepository.php.

◆ getModel()

getModel ( )
abstractprotected

Reimplemented in Repository.

◆ insert()

insert ( object  $instance,
bool  $insertMany = false 
)

Insert a new instance $instance into the database.

Parameters
object$instance
bool$insertMany
Returns
bool
Exceptions

Exception

Definition at line 84 of file AbstractRepository.php.

◆ one()

one ( string  $condition = '',
  $included = true,
array  $parameters = [ ],
bool  $useCache = false 
)

Load one instance.

Parameters
string$condition
bool | array$included
array$parameters
bool$useCache
Returns
?object
Exceptions

Ubiquity\exceptions\DAOException

Definition at line 72 of file AbstractRepository.php.

◆ orderBy()

orderBy ( string  $field,
string  $order = 'ASC',
string  $condition = '',
  $included = false,
array  $parameters = [ ],
bool  $useCache = false 
)

Load all instances with order.

Parameters
string$fieldThe field to order by
string$orderThe order (ASC, DESC)
string$conditionThe condition
bool | array$includedThe relations to include
array$parametersThe parameters for the condition
bool$useCacheIf true, use the cache
Returns
array

Definition at line 46 of file AbstractRepository.php.

◆ remove()

remove ( object  $instance)

Remove an instance $instance from the database.

Parameters
object$instance
Returns
int|null

Definition at line 116 of file AbstractRepository.php.

◆ save()

save ( object  $instance,
bool  $insertMany = false 
)

Save (insert or update) an instance $instance in the database.

Parameters
object$instance
bool$insertMany
Returns
bool|int

Definition at line 106 of file AbstractRepository.php.

◆ update()

update ( object  $instance,
bool  $insertMany = false 
)

Update an instance $instance in the database.

Parameters
object$instance
bool$insertMany
Returns
bool

Definition at line 95 of file AbstractRepository.php.


The documentation for this class was generated from the following file: