You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
2.1 KiB
87 lines
2.1 KiB
<?php
|
|
|
|
namespace Gateway;
|
|
use PDO;
|
|
|
|
class ImageGateway
|
|
{
|
|
private Connection $co;
|
|
|
|
public function __construct(Connection $co)
|
|
{
|
|
$this -> co = $co;
|
|
}
|
|
|
|
public function createImgGateway(int $idImg, string $imgPath, bool $isImgProfile) : bool
|
|
{
|
|
$query = "
|
|
INSERT INTO Images
|
|
VALUES (:id_img, :img_path, :is_img_profile)
|
|
";
|
|
|
|
return $this -> co -> executeQuery($query, [
|
|
'id_img' => array($idImg, PDO::PARAM_INT),
|
|
'img_path' => array($imgPath, PDO::PARAM_STR),
|
|
'is_img_profile' => array($isImgProfile, PDO::PARAM_BOOL),
|
|
]);
|
|
}
|
|
|
|
public function findImgById(int $idImg) : array
|
|
{
|
|
$query = "
|
|
SELECT * FROM Images
|
|
WHERE id_image = :id_img
|
|
";
|
|
|
|
$this -> co -> executeQuery($query, ['id_img' => array($idImg, PDO::PARAM_INT)]);
|
|
|
|
return $this -> co -> getResults();
|
|
}
|
|
|
|
public function findAllImg() : array
|
|
{
|
|
$query = "
|
|
SELECT * FROM Images
|
|
";
|
|
|
|
$this -> co -> executeQuery($query);
|
|
|
|
return $this -> co -> getResults();
|
|
}
|
|
|
|
public function findAllImgProfile() : array
|
|
{
|
|
$query = "
|
|
SELECT * FROM Images
|
|
WHERE is_img_prfl
|
|
";
|
|
|
|
$this -> co -> executeQuery($query);
|
|
|
|
return $this -> co -> getResults();
|
|
}
|
|
|
|
public function deleteImgGateway(int $idImg) : bool
|
|
{
|
|
$query = "
|
|
DELETE FROM Images
|
|
WHERE id_image = :id_img
|
|
";
|
|
|
|
return $this -> co -> executeQuery($query, ['id_img' => array($idImg, PDO::PARAM_INT)]);
|
|
}
|
|
|
|
public function updateImgGateway(int $idImg, string $imgPath) : bool
|
|
{
|
|
$query = "
|
|
UPDATE Images
|
|
SET img_path = :img_path
|
|
WHERE id_image = :id_img
|
|
";
|
|
|
|
return $this -> co -> executeQuery($query, [
|
|
'id_img' => array($idImg, PDO::PARAM_INT),
|
|
'img_path' => array($imgPath, PDO::PARAM_STR)
|
|
]);
|
|
}
|
|
} |