ajout méthode find dans le model

This commit is contained in:
2023-11-04 09:43:58 +01:00
parent aa551c697b
commit 39eb008118
2 changed files with 37 additions and 1 deletions

View File

@@ -31,6 +31,11 @@ class Model
return $this;
}
public function getValues(): array
{
return $this->values;
}
public function getPk(): string
{
return $this->pk;
@@ -61,6 +66,19 @@ class Model
return $this;
}
public function find(mixed $key): bool
{
$res = false;
$qb = $this->newQueryBuilder();
$find = $qb->find($key);
if($find!==null)
{
$this->fillData($find->getValues());
$res = true;
}
return $res;
}
public function save(): bool
{
$ret = false;
@@ -121,5 +139,6 @@ class Model
$table = strtolower($classNameWithoutNamespace);
return $table;
}
}
}