23 $this->view->setVar ( $viewVar, $instance );
24 $this->view->setVar (
'status', $r );
29 $this->view = $ctrl->
getView ();
43 public function all(
string $condition =
'', $included =
false, array $parameters = [ ],
bool $useCache =
false,
string $viewVar =
'all'): array {
44 $this->view->setVar ( $viewVar, $r =
DAO::getAll ( $this->model, $condition, $included, $parameters, $useCache ) );
57 public function byId($keyValues, $included =
true,
bool $useCache =
false,
string $viewVar =
'byId'): ?object {
58 $this->view->setVar ( $viewVar, $r =
DAO::getById ( $this->model, $keyValues, $included, $useCache ) );
73 public function one(
string $condition =
'', $included =
true, array $parameters = [ ],
bool $useCache =
false,
string $viewVar =
'one'): ?object {
74 $this->view->setVar ( $viewVar, $r =
DAO::getOne ( $this->model, $condition, $included, $parameters, $useCache ) );
88 public function insert(
object $instance, $insertMany =
false,
string $viewVar =
'inserted'): bool {
89 $r =
DAO::insert ( $instance, $insertMany );
90 return $this->setViewVarsAndReturn ( $viewVar, $instance, $r );
102 public function update(
object $instance, $insertMany =
false,
string $viewVar =
'updated'): bool {
103 $r =
DAO::update ( $instance, $insertMany );
104 return $this->setViewVarsAndReturn ( $viewVar, $instance, $r );
116 public function save(
object $instance, $insertMany =
false,
string $viewVar =
'saved') {
117 $r = DAO::save ( $instance, $insertMany );
118 return $this->setViewVarsAndReturn ( $viewVar, $instance, $r );
128 public function remove(
object $instance,
string $viewVar =
'removed'): ?int {
129 $r =
DAO::remove ( $instance );
130 return $this->setViewVarsAndReturn ( $viewVar, $instance, $r );
Base class for controllers.
getView()
Returns the associated view instance.
Gateway class between database and object model.
A repository for managing CRUD operations on a model, displayed in a view.
insert(object $instance, $insertMany=false, string $viewVar='inserted')
Insert a new instance $instance into the database and add the instance in a view variable (inserted).
byId($keyValues, $included=true, bool $useCache=false, string $viewVar='byId')
Load one instance by id in a view variable named byId.
all(string $condition='', $included=false, array $parameters=[], bool $useCache=false, string $viewVar='all')
Load all instances in a view variable named all.
save(object $instance, $insertMany=false, string $viewVar='saved')
Save (insert or update) an instance $instance in the database and add the instance in a view variable...
one(string $condition='', $included=true, array $parameters=[], bool $useCache=false, string $viewVar='one')
Load one instance in a view variable named one.
setViewVarsAndReturn(string $viewVar, $instance, $r)
update(object $instance, $insertMany=false, string $viewVar='updated')
Update an instance $instance in the database and add the instance in a view variable (updated).
__construct(Controller $ctrl, string $model)