Optimized ExecuteDbStatement error handling

This commit is contained in:
Bernd Bestel 2026-09-04 10:44:01 +02:00
parent 3c8edb515c
commit 10b7b446cf
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300

View File

@ -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()));
}
}