ajout méthode find dans le model
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user