--- /dev/null
+<?php
+
+ require_once('protected/required.php');
+
+ class PdoClientManager extends AbstractPdoManager {
+
+ public function createClient($client) {
+
+ $query = $this -> pdo -> prepare(
+ 'INSERT INTO clients (
+ identifiant_AP,
+ nom
+ ) VALUES (
+ :identifiant_AP,
+ :nom
+ );'
+ );
+ $query -> bindValue(':identifiant_AP', $client -> getIdentifiantAP());
+ $query -> bindValue(':nom', $client -> getNom());
+ $query -> execute();
+ }
+
+ public function updateClient($client) {
+
+ $query = $this -> pdo -> prepare(
+ 'UPDATE clients
+ SET identifiant_AP = :identifiant_AP,
+ nom = :nom
+ WHERE id = :id'
+ );
+ $query -> bindValue(':id', $client -> getId());
+ $query -> bindValue(':identifiant_AP', $client -> getIdentifiantAP());
+ $query -> bindValue(':nom', $client -> getNom());
+ $query -> execute();
+ }
+
+ public function getClient($id) {
+
+ $query = $this -> pdo -> prepare('SELECT * FROM clients WHERE id = :id');
+ $query -> bindValue(':id', $id);
+ $query -> execute();
+
+ $result = $query -> fetch(PDO::FETCH_ASSOC);
+ $client = new Client($result['id'], $result['identifiant_AP'], $result['nom']);
+
+ $query->closeCursor();
+
+ return $client;
+ }
+
+ public function getClientByIdentifiantAP($identifiantAP) {
+
+ $query = $this -> pdo -> prepare('SELECT * FROM clients WHERE identifiant_AP = :identifiant_AP');
+ $query -> bindValue(':identifiant_AP', $identifiantAP);
+ $query -> execute();
+
+ $result = $query -> fetch(PDO::FETCH_ASSOC);
+ $client = new Client($result['id'], $result['identifiant_AP'], $result['nom']);
+
+ $query->closeCursor();
+
+ return $client;
+ }
+
+ public function getClients() {
+
+ $query = $this -> pdo -> prepare('SELECT * FROM clients');
+ $query -> execute();
+
+ $results = $query -> fetchAll(PDO::FETCH_ASSOC);
+ $clients = array();
+ foreach ($results as $result) {
+ $clients[] = new Client($result['id'], $result['identifiant_AP'], $result['nom']);
+ }
+
+ $query->closeCursor();
+
+ return $clients;
+ }
+
+ public function removeClient($client) {
+
+ $query = $this -> pdo -> prepare('DELETE FROM clients WHERE id = :id');
+ $query -> bindValue('id', $client -> getId());
+ $query -> execute();
+ }
+
+ }
+
+?>