asdsad
This commit is contained in:
@@ -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);
|
||||
}
|
||||
if (defined('APP_ENV') && APP_ENV === 'staging') {
|
||||
$ph = [];
|
||||
if (preg_match_all('/:([a-zA-Z0-9_]+)/', $sql, $m)) {
|
||||
$ph = array_unique($m[0]);
|
||||
}
|
||||
$stmt->bindValue($paramName, $value, \PDO::PARAM_STR);
|
||||
$paramKeys = array_keys($bind);
|
||||
error_log('Search placeholders: ' . json_encode($ph));
|
||||
error_log('Search params: ' . json_encode($paramKeys));
|
||||
}
|
||||
// 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);
|
||||
try {
|
||||
$stmt->execute();
|
||||
} catch (\PDOException $e) {
|
||||
error_log('Search SQL: ' . $sql);
|
||||
error_log('Search bind: ' . print_r($bind, true));
|
||||
throw $e;
|
||||
}
|
||||
$stmt->execute();
|
||||
return $stmt->fetchAll(\PDO::FETCH_ASSOC) ?: [];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user