--- /dev/null
+<?php
+
+ require_once('protected/required.php');
+
+ class PdoWarningManager extends AbstractPdoManager {
+
+ public function createWarning($warning) {
+
+ $query = $this -> pdo -> prepare(
+ 'INSERT INTO warnings (creation, nature, message, version) VALUES (NOW(), :nature, :message, :version);'
+ );
+ $query -> bindValue(':nature', $warning -> getNature());
+ $query -> bindValue(':message', $warning -> getMessage());
+ $query -> bindValue(':version', $warning -> getVersion());
+ $query -> execute();
+ }
+
+ public function updateWarning($warning) {
+
+ $query = $this -> pdo -> prepare(
+ 'UPDATE warnings
+ SET creation = :creation,
+ nature = :nature,
+ message = :message,
+ version = :version
+ WHERE id = :id'
+ );
+ $query -> bindValue(':id', $warning -> getId());
+ $query -> bindValue(':creation', $warning -> getCreation());
+ $query -> bindValue(':nature', $warning -> getNature());
+ $query -> bindValue(':message', $warning -> getMessage());
+ $query -> bindValue(':version', $warning -> getVersion());
+ $query -> execute();
+ }
+
+ public function getWarning($id) {
+
+ $query = $this -> pdo -> prepare('SELECT * FROM warnings WHERE id = :id');
+ $query -> bindValue(':id', $id);
+ $query -> execute();
+
+ $result = $query -> fetch(PDO::FETCH_ASSOC);
+ $warning = new Warning($result['id'], $result['creation'], $result['nature'], $result['message'], $result['version']);
+
+ $query->closeCursor();
+
+ return $warning;
+ }
+
+ public function getLastWarning() {
+
+ $query = $this -> pdo -> prepare('SELECT * FROM warnings WHERE id = LAST_INSERT_ID()');
+ $query -> execute();
+
+ $result = $query -> fetch(PDO::FETCH_ASSOC);
+ $warning = new Warning($result['id'], $result['creation'], $result['nature'], $result['message'], $result['version']);
+
+ $query->closeCursor();
+
+ return $warning;
+ }
+
+ public function getWarnings() {
+
+ $query = $this -> pdo -> prepare('SELECT * FROM warnings');
+ $query -> execute();
+
+ $results = $query -> fetchAll(PDO::FETCH_ASSOC);
+ $warnings = array();
+ foreach ($results as $result) {
+ $warnings[] = new Warning($result['id'], $result['creation'], $result['nature'], $result['message'], $result['version']);
+ }
+
+ $query->closeCursor();
+
+ return $warnings;
+ }
+
+ public function removeWarning($warning) {
+
+ $query = $this -> pdo -> prepare('DELETE FROM warnings WHERE id = :id');
+ $query -> bindValue('id', $warning -> getId());
+ $query -> execute();
+ }
+
+ }