1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
| <?php
/**
*class qui va permettre de faire le lien entre la BDD et la illustration
**/
class IllustrationManager
{
/**
* Attribut contenant l'instance représentant la BDD
* @type PDO
*/
private $db;
/**
* Constructeur étant chargé d'enregistrer l'instance de PDO dans l'attribut $db
**/
public function __construct($db)
{
$this->db = $db;
}
/**
* Méthode vérifiant si l illustration existe
* @param $email string
* @return bool
*/
public function getCouverture($idProduit)
{
$requete = $this->db->prepare('SELECT id,legende,position,idProduit
FROM illustration_produit WHERE id = :idProduit');
$requete->bindValue(':idProduit', (int) $idProduit, PDO::PARAM_INT);
$requete->execute();
return new Illustration($requete->fetch(PDO::FETCH_ASSOC));
}
/**
* Méthode retournant une liste de illustration demandée sans la illustration Accueil
* @param $debut int La première illustration à sélectionner
* @param $limite int Le nombre de illustration à sélectionner
* @return array La liste des illustration.Chaque illustration entrée est une instance de illustration.
*/
public function getList($debut = -1, $limite = -1)
{
$listeIllustration = array();
$sql = 'SELECT id,legende,position,idProduit
FROM illustration_produit ORDER BY id ASC';
if ($debut != -1 || $limite != -1)
$sql .= ' LIMIT ' . (int) $debut . ', ' . (int) $limite;
$requete = $this->db->query($sql);
while ($illustration = $requete->fetch(PDO::FETCH_ASSOC))
$listeIllustration[] = new Illustration($illustration);
$requete->closeCursor();
return $listeIllustration;
}
/**
* Méthode retournant les proprietes d un illustration précise
* @param $id int L'identifiant de l illustration à récupérer
* @return illustration La illustration demandée
*/
public function getUnique($id)
{
$requete = $this->db->prepare('SELECT id,legende,position,idProduit
FROM illustration_produit WHERE id = :id');
$requete->bindValue(':id', (int) $id, PDO::PARAM_INT);
$requete->execute();
return new illustration($requete->fetch(PDO::FETCH_ASSOC));
}
?> |
Partager