Debuggy time

This commit is contained in:
Lewis Dale 2023-08-27 21:36:01 +01:00
parent 16e0a8f381
commit 9164929969
2 changed files with 7 additions and 2 deletions

View File

@ -12,7 +12,7 @@ $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"]}")); $imageDb = new SqliteImageDb(new PDO("sqlite:{$_ENV["db_name"]}"), $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);

View File

@ -5,10 +5,12 @@ namespace ImageResizer\Lib;
use ImageResizer\Models\Image; use ImageResizer\Models\Image;
use ImageResizer\Models\ResizeParams; use ImageResizer\Models\ResizeParams;
use Psr\Log\AbstractLogger;
class SqliteImageDb implements ImageDb { class SqliteImageDb implements ImageDb {
public function __construct( public function __construct(
private readonly \PDO $db private readonly \PDO $db,
private readonly AbstractLogger $logger,
) { ) {
$this->up(); $this->up();
} }
@ -22,6 +24,9 @@ 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 {