Fix query to handle null params
This commit is contained in:
parent
3949e611ea
commit
782c5b4b38
@ -27,7 +27,12 @@ class SqliteImageDb implements ImageDb {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function findImage(string $path, ResizeParams $params): Image | null {
|
public function findImage(string $path, ResizeParams $params): Image | null {
|
||||||
$stmt = $this->db->prepare('SELECT * FROM images WHERE path = :path AND width = :width AND height = :height AND quality = :quality');
|
$query = "SELECT * FROM images WHERE path = :path";
|
||||||
|
$query .= $params->width ? " AND width = :width" : " AND width IS NULL";
|
||||||
|
$query .= $params->height ? " AND height = :height" : " AND height IS NULL";
|
||||||
|
$query .= $params->quality ? " AND quality = :quality" : " AND quality IS NULL";
|
||||||
|
|
||||||
|
$stmt = $this->db->prepare($query);
|
||||||
$stmt->execute([
|
$stmt->execute([
|
||||||
':path' => $path,
|
':path' => $path,
|
||||||
':width' => $params->width,
|
':width' => $params->width,
|
||||||
|
Loading…
Reference in New Issue
Block a user