Commit 0a38d669 by Scott

Cast integer database parameters

parent fe62af54
......@@ -222,7 +222,12 @@ class DbConnection
$stmt = $this->pdo->prepare($query);
// PDO quotes parameters by default, which breaks LIMIT clauses, so we bind parameters manually
foreach (array_values($params) as $i => $param) {
$dataType = filter_var($param, FILTER_VALIDATE_INT) !== false ? PDO::PARAM_INT : PDO::PARAM_STR;
if (filter_var($param, FILTER_VALIDATE_INT) !== false) {
$dataType = PDO::PARAM_INT;
$param = (int) $param;
} else {
$dataType = PDO::PARAM_STR;
}
$stmt->bindValue($i + 1, $param, $dataType);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment