mirror of
https://github.com/grocy/grocy.git
synced 2026-10-17 05:14:20 +02:00
Optimized ExecuteDbStatement error handling
This commit is contained in:
parent
3c8edb515c
commit
10b7b446cf
|
|
@ -36,20 +36,25 @@ class DatabaseService
|
|||
}
|
||||
}
|
||||
|
||||
if ($params == null)
|
||||
if ($params === null)
|
||||
{
|
||||
|
||||
if ($pdo->exec($sql) === false)
|
||||
{
|
||||
throw new \Exception($pdo->errorInfo());
|
||||
throw new \Exception(implode(' | ', $pdo->errorInfo()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$cmd = $pdo->prepare($sql);
|
||||
|
||||
if ($cmd === false)
|
||||
{
|
||||
throw new \Exception(implode(' | ', $pdo->errorInfo()));
|
||||
}
|
||||
|
||||
if ($cmd->execute($params) === false)
|
||||
{
|
||||
throw new \Exception($pdo->errorInfo());
|
||||
throw new \Exception(implode(' | ', $cmd->errorInfo()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user