Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
AbstractRepository.php
Go to the documentation of this file.
1<?php
2
4
8
18abstract class AbstractRepository {
19
20 abstract protected function getModel(): string;
21
31 public function all(string $condition = '', $included = false, array $parameters = [ ], bool $useCache = false): array {
32 return DAO::getAll ( $this->getModel (), $condition, $included, $parameters, $useCache );
33 }
34
46 public function orderBy(string $field, string $order='ASC', string $condition = '', $included = false, array $parameters = [ ], bool $useCache = false): array {
47 return DAO::orderBy($this->getModel(), $field, $order, $condition, $included, $parameters, $useCache);
48 }
49
58 public function byId($keyValues, $included = true, bool $useCache = false): ?object {
59 return DAO::getById ( $this->getModel (), $keyValues, $included, $useCache );
60 }
61
72 public function one(string $condition = '', $included = true, array $parameters = [ ], bool $useCache = false): ?object {
73 return DAO::getOne ( $this->getModel (), $condition, $included, $parameters, $useCache );
74 }
75
84 public function insert(object $instance, bool $insertMany = false): bool {
85 return DAO::insert ( $instance, $insertMany );
86 }
87
95 public function update(object $instance, bool $insertMany = false): bool {
96 return DAO::update ( $instance, $insertMany );
97 }
98
106 public function save(object $instance, bool $insertMany = false) {
107 return DAO::save ( $instance, $insertMany );
108 }
109
116 public function remove(object $instance): ?int {
117 return DAO::remove ( $instance );
118 }
119
127 public function count(string $condition='',?array $parameters=null):int {
128 return DAO::count($this->getModel(),$condition,$parameters);
129 }
130}
Base class for controllers.
Gateway class between database and object model.
Definition DAO.php:33
A repository for managing CRUD operations on a model.
byId($keyValues, $included=true, bool $useCache=false)
Load one instance by id.
update(object $instance, bool $insertMany=false)
Update an instance $instance in the database.
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.
save(object $instance, bool $insertMany=false)
Save (insert or update) an instance $instance in the database.
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.
count(string $condition='',?array $parameters=null)
Returns the number of instances.
Represents a view.
Definition View.php:17