Refatoring : Working state
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user