asdsad
This commit is contained in:
@@ -89,22 +89,34 @@ final class Search
|
|||||||
$type = is_int($value) ? \PDO::PARAM_INT : \PDO::PARAM_STR;
|
$type = is_int($value) ? \PDO::PARAM_INT : \PDO::PARAM_STR;
|
||||||
$stmt->bindValue($paramName, $value, $type);
|
$stmt->bindValue($paramName, $value, $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined('APP_ENV') && APP_ENV === 'staging') {
|
if (defined('APP_ENV') && APP_ENV === 'staging') {
|
||||||
$ph = [];
|
$ph = [];
|
||||||
if (preg_match_all('/:([a-zA-Z0-9_]+)/', $sql, $m)) {
|
if (preg_match_all('/:([a-zA-Z0-9_]+)/', $sql, $m)) {
|
||||||
$ph = array_unique($m[0]);
|
$ph = array_unique($m[0]);
|
||||||
}
|
}
|
||||||
$paramKeys = array_keys($bind);
|
$paramKeys = array_keys($bind);
|
||||||
error_log('Search placeholders: ' . json_encode($ph));
|
$log = [
|
||||||
error_log('Search params: ' . json_encode($paramKeys));
|
'placeholders' => $ph,
|
||||||
|
'params' => $paramKeys,
|
||||||
|
'sql' => $sql,
|
||||||
|
'bind' => $bind,
|
||||||
|
];
|
||||||
|
@file_put_contents(__DIR__ . '/../../debug/search_debug.log', print_r($log, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
return $stmt->fetchAll(\PDO::FETCH_ASSOC) ?: [];
|
||||||
} catch (\PDOException $e) {
|
} catch (\PDOException $e) {
|
||||||
error_log('Search SQL: ' . $sql);
|
// Log into /debug/search_debug.log and continue with empty results
|
||||||
error_log('Search bind: ' . print_r($bind, true));
|
$logErr = [
|
||||||
throw $e;
|
'error' => $e->getMessage(),
|
||||||
|
'sql' => $sql,
|
||||||
|
'bind' => $bind,
|
||||||
|
];
|
||||||
|
@file_put_contents(__DIR__ . '/../../debug/search_debug.log', print_r($logErr, true));
|
||||||
|
return [];
|
||||||
}
|
}
|
||||||
return $stmt->fetchAll(\PDO::FETCH_ASSOC) ?: [];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user