From 2060e198b1f9ac41deee93848417121fb1c066f5 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Sun, 18 Mar 2018 03:48:04 +0100 Subject: classes fonctionnelles --- class/class.app.php | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'class/class.app.php') diff --git a/class/class.app.php b/class/class.app.php index d9867d3..ad62c25 100644 --- a/class/class.app.php +++ b/class/class.app.php @@ -1,4 +1,3 @@ -

class.app

exist($art->id())) { - echo '

cet id existe deja

'; + echo '

cet id existe deja

'; } else { $now = new DateTimeImmutable(null, timezone_open("Europe/Paris")); @@ -72,21 +71,36 @@ class App $list = []; $req = $this->bdd->query('SELECT * FROM art ORDER BY id'); - while ($donnees = $req->fetch(PDO::FETCH_ASSOC)) - { - $list[] = new Art($donnees); + while ($donnees = $req->fetch(PDO::FETCH_ASSOC)) { + $list[] = new Art($donnees); } return $list; } + public function menu($session) + { + $req = $this->bdd->query('SELECT * FROM art ORDER BY id'); + echo ' '; + + } + public function count() { - return $this->bdd->query('SELECT COUNT(*) FROM art')->fetchColumn(); + return $this->bdd->query(' SELECT COUNT(*) FROM art ')->fetchColumn(); } public function exist($id) { - $req = $this->bdd->prepare('SELECT COUNT(*) FROM art WHERE id = :id '); + $req = $this->bdd->prepare(' SELECT COUNT(*) FROM art WHERE id = :id '); $req->execute(array('id' => $id)); $donnees = $req->fetch(PDO::FETCH_ASSOC); @@ -98,17 +112,17 @@ class App $now = new DateTimeImmutable(null, timezone_open("Europe/Paris")); $q = $this->bdd->prepare('UPDATE art SET titre = :titre, soustitre = :soustitre, intro = :intro, tag = :tag, datecreation = :datecreation, datemodif = :datemodif, css = :css, html = :html, secure = :secure, couleurtext = :couleurtext, couleurbkg = :couleurbkg, couleurlien = :couleurlien WHERE id = :id'); - + $q->bindValue(':id', $art->id()); $q->bindValue(':titre', $art->titre()); $q->bindValue(':soustitre', $art->soustitre()); $q->bindValue(':intro', $art->intro()); $q->bindValue(':tag', $art->tag()); - $q->bindValue(':datecreation', $art->datecreation()->format('Y-m-d H:i:s')); + $q->bindValue(':datecreation', $art->datecreation('string')); $q->bindValue(':datemodif', $now->format('Y-m-d H:i:s')); $q->bindValue(':css', $art->css()); $q->bindValue(':html', $art->html()); - $q->bindValue(':secure', $art->secure(), PDO::PARAM_INT); + $q->bindValue(':secure', $art->secure()); $q->bindValue(':couleurtext', $art->couleurtext()); $q->bindValue(':couleurbkg', $art->couleurbkg()); $q->bindValue(':couleurlien', $art->couleurlien()); @@ -116,6 +130,5 @@ class App $q->execute(); } - } ?> \ No newline at end of file -- cgit v1.2.3