Fix broken database

This commit is contained in:
Lewis Dale 2023-08-27 21:41:49 +01:00
parent 9164929969
commit 3949e611ea
2 changed files with 4 additions and 4 deletions

View File

@ -12,7 +12,8 @@ $logger = new FileLogger("resizer.log");
$dotenv = Dotenv\Dotenv::createImmutable([__DIR__, __DIR__ . "/.."]);
$dotenv->load();
$imageDb = new SqliteImageDb(new PDO("sqlite:{$_ENV["db_name"]}"), $logger);
$pdo = new PDO("sqlite:".$_ENV["DB_NAME"]);
$imageDb = new SqliteImageDb($pdo, $logger);
$imgPath = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$params = new ResizeParams($_GET);

View File

@ -24,9 +24,6 @@ class SqliteImageDb implements ImageDb {
quality INTEGER NULLABLE,
content TEXT NOT NULL
)');
$crs = $this->db->query('SELECT * FROM images');
$this->logger->info('Found something', ['results '=> $crs->fetchAll()]);
}
public function findImage(string $path, ResizeParams $params): Image | null {
@ -38,6 +35,8 @@ class SqliteImageDb implements ImageDb {
':quality' => $params->quality
]);
$this->logger->info("Querying images", ['query' => $stmt->queryString]);
$result = $stmt->fetchObject();
return $result ? Image::fromString(base64_decode($result->content)) : null;