This commit is contained in:
2026-01-02 01:03:10 +01:00
parent a856086ce1
commit 1b077e10e2

View File

@@ -83,28 +83,28 @@ final class Search
$sql .= " LIMIT :lim";
$bind[':lim'] = (int)$limit;
echo '<pre>';
print_r($bind);
echo '</pre>';
echo $sql;
$stmt = $this->pdo->prepare($sql);
foreach ($bind as $name => $value) {
$paramName = $name;
if ($name[0] !== ':') {
$paramName = ':' . $name;
$paramName = $name[0] === ':' ? $name : ':' . $name;
$type = is_int($value) ? \PDO::PARAM_INT : \PDO::PARAM_STR;
$stmt->bindValue($paramName, $value, $type);
}
$stmt->bindValue($paramName, $value, \PDO::PARAM_STR);
if (defined('APP_ENV') && APP_ENV === 'staging') {
$ph = [];
if (preg_match_all('/:([a-zA-Z0-9_]+)/', $sql, $m)) {
$ph = array_unique($m[0]);
}
// Limit als INT binden
$stmt->bindValue(':lim', (int)$bind[':lim'] ?? (int)$bind['lim'] ?? (int)$limit, \PDO::PARAM_INT);
// Radius nur falls existiert
if ($distanceFiltering) {
$stmt->bindValue(':radius', $bind[':radius'] ?? $bind['radius'], \PDO::PARAM_STR);
$paramKeys = array_keys($bind);
error_log('Search placeholders: ' . json_encode($ph));
error_log('Search params: ' . json_encode($paramKeys));
}
try {
$stmt->execute();
} catch (\PDOException $e) {
error_log('Search SQL: ' . $sql);
error_log('Search bind: ' . print_r($bind, true));
throw $e;
}
return $stmt->fetchAll(\PDO::FETCH_ASSOC) ?: [];
}
}