Refatoring : Working state

This commit is contained in:
julien
2026-03-16 16:02:01 +01:00
parent a5ca0df375
commit 0453697cd3
25 changed files with 111 additions and 97 deletions

View File

@@ -7,6 +7,9 @@ use App\Media\Media;
use App\Media\MediaRepositoryInterface;
use PDO;
/**
* Implémentation PDO du repository Media.
*/
class PdoMediaRepository implements MediaRepositoryInterface
{
private const SELECT = 'SELECT id, filename, url, hash, user_id, created_at FROM media';
@@ -85,15 +88,6 @@ class PdoMediaRepository implements MediaRepositoryInterface
return $row ? Media::fromArray($row) : null;
}
public function findByHash(string $hash): ?Media
{
$stmt = $this->db->prepare(self::SELECT . ' WHERE hash = :hash ORDER BY id DESC LIMIT 1');
$stmt->execute([':hash' => $hash]);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
return $row ? Media::fromArray($row) : null;
}
public function findByHashForUser(string $hash, int $userId): ?Media
{
$stmt = $this->db->prepare(self::SELECT . ' WHERE hash = :hash AND user_id = :user_id ORDER BY id DESC LIMIT 1');