Actually fix the query and caching
This commit is contained in:
parent
a9e8b61e0b
commit
e2cf30a307
@ -27,21 +27,21 @@ class SqliteImageDb implements ImageDb {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function findImage(string $path, ResizeParams $params): Image | null {
|
public function findImage(string $path, ResizeParams $params): Image | null {
|
||||||
$query = "SELECT * FROM images WHERE path = :path";
|
$query = 'SELECT * FROM images WHERE path = :path';
|
||||||
$query .= $params->width ? " AND width = :width" : " AND width IS NULL";
|
$query .= $params->width ? ' AND width = :width' : ' AND width IS NULL';
|
||||||
$query .= $params->height ? " AND height = :height" : " AND height IS NULL";
|
$query .= $params->height ? ' AND height = :height' : ' AND height IS NULL';
|
||||||
$query .= $params->quality ? " AND quality = :quality" : " AND quality IS NULL";
|
$query .= $params->quality ? ' AND quality = :quality' : ' AND quality IS NULL';
|
||||||
|
|
||||||
$stmt = $this->db->prepare($query);
|
$stmt = $this->db->prepare($query);
|
||||||
$stmt->execute([
|
$stmt->bindParam(':path', $path);
|
||||||
':path' => $path,
|
if ($params->width !== null) $stmt->bindParam(':width', $params->width);
|
||||||
':width' => $params->width,
|
if ($params->height !== null) $stmt->bindParam(':height', $params->height);
|
||||||
':height' => $params->height,
|
if ($params->quality !== null) $stmt->bindParam(':quality', $params->quality);
|
||||||
':quality' => $params->quality
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->logger->info("Querying images", ['query' => $stmt->queryString]);
|
$this->logger->info("Querying images", ['query' => $stmt->queryString]);
|
||||||
|
|
||||||
|
$stmt->execute();
|
||||||
|
|
||||||
$result = $stmt->fetchObject();
|
$result = $stmt->fetchObject();
|
||||||
|
|
||||||
return $result ? Image::fromString(base64_decode($result->content)) : null;
|
return $result ? Image::fromString(base64_decode($result->content)) : null;
|
||||||
|
Loading…
Reference in New Issue
Block a user