Fix broken database
This commit is contained in:
parent
9164929969
commit
3949e611ea
@ -12,7 +12,8 @@ $logger = new FileLogger("resizer.log");
|
|||||||
$dotenv = Dotenv\Dotenv::createImmutable([__DIR__, __DIR__ . "/.."]);
|
$dotenv = Dotenv\Dotenv::createImmutable([__DIR__, __DIR__ . "/.."]);
|
||||||
$dotenv->load();
|
$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);
|
$imgPath = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
|
||||||
$params = new ResizeParams($_GET);
|
$params = new ResizeParams($_GET);
|
||||||
|
@ -24,9 +24,6 @@ class SqliteImageDb implements ImageDb {
|
|||||||
quality INTEGER NULLABLE,
|
quality INTEGER NULLABLE,
|
||||||
content TEXT NOT NULL
|
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 {
|
public function findImage(string $path, ResizeParams $params): Image | null {
|
||||||
@ -38,6 +35,8 @@ class SqliteImageDb implements ImageDb {
|
|||||||
':quality' => $params->quality
|
':quality' => $params->quality
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$this->logger->info("Querying images", ['query' => $stmt->queryString]);
|
||||||
|
|
||||||
$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