ajout des transactions

This commit is contained in:
Gregory Letellier
2023-11-06 10:17:40 +01:00
parent 39eb008118
commit 9db5e9b2bd
2 changed files with 26 additions and 4 deletions

View File

@@ -160,6 +160,30 @@ class Connection
}
}
public function beginTransaction(): bool
{
if ($this->pdo) {
return $this->pdo->beginTransaction();
}
return false;
}
public function commit(): bool
{
if ($this->pdo) {
return $this->pdo->commit();
}
return false;
}
public function rollback(): bool
{
if ($this->pdo) {
return $this->pdo->rollBack();
}
return false;
}
public static function init($config, array $connections = ["default"])
{
self::fillInstances($config, $connections);

View File

@@ -71,8 +71,7 @@ class Model
$res = false;
$qb = $this->newQueryBuilder();
$find = $qb->find($key);
if($find!==null)
{
if ($find !== null) {
$this->fillData($find->getValues());
$res = true;
}
@@ -139,6 +138,5 @@ class Model
$table = strtolower($classNameWithoutNamespace);
return $table;
}
}
}