Use bind params when copying a recipe (fixes #2337)

This commit is contained in:
Bernd Bestel
2023-09-15 13:58:57 +02:00
parent 1e60f940e4
commit 3308e79027
3 changed files with 19 additions and 7 deletions

View File

@@ -23,7 +23,7 @@ class DatabaseService
return false;
}
public function ExecuteDbStatement(string $sql)
public function ExecuteDbStatement(string $sql, array $params = null)
{
$pdo = $this->GetDbConnectionRaw();
@@ -36,9 +36,21 @@ class DatabaseService
}
}
if ($pdo->exec($sql) === false)
if ($params == null)
{
throw new \Exception($pdo->errorInfo());
if ($pdo->exec($sql) === false)
{
throw new \Exception($pdo->errorInfo());
}
}
else
{
$cmd = $pdo->prepare($sql);
if ($cmd->execute($params) === false)
{
throw new \Exception($pdo->errorInfo());
}
}
return true;