diff options
author | vincent-peugnet <v.peugnet@free.fr> | 2018-03-18 03:48:04 +0100 |
---|---|---|
committer | vincent-peugnet <v.peugnet@free.fr> | 2018-03-18 03:48:04 +0100 |
commit | 2060e198b1f9ac41deee93848417121fb1c066f5 (patch) | |
tree | ff3abf3f4af68cef081d19f3aa935079bdf25ad6 /class/class.app.php | |
parent | 3650a038f0a6c99d52723e9567d5f173c4398c3a (diff) | |
download | wcms-2060e198b1f9ac41deee93848417121fb1c066f5.tar.gz wcms-2060e198b1f9ac41deee93848417121fb1c066f5.zip |
classes fonctionnelles
Diffstat (limited to 'class/class.app.php')
-rw-r--r-- | class/class.app.php | 35 |
1 files changed, 24 insertions, 11 deletions
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 @@ -<h4>class.app</h4> <?php class App { @@ -23,7 +22,7 @@ class App { if ($this->exist($art->id())) { - echo '<p>cet id existe deja</p>'; + echo '<h4>cet id existe deja</h4>'; } 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 '<ul>'; + while ($donnees = $req->fetch(PDO::FETCH_ASSOC)) { + echo '<li><a href="?id=' . $donnees['id'] . '&display=1">' . $donnees['titre'] . '</a> - ' . $donnees['intro']; + if ($session >= 2) { + echo ' - <a href="?id=' . $donnees['id'] . '&edit=1">modifier</a></li>'; + } else { + echo '</li>'; + } + } + echo ' </ul> '; + + } + 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 |