diff options
author | vincent-peugnet <v.peugnet@free.fr> | 2018-10-31 15:28:37 +0100 |
---|---|---|
committer | vincent-peugnet <v.peugnet@free.fr> | 2018-10-31 15:28:37 +0100 |
commit | 26f88e043ebedcadd337011ce527f6148350f0dc (patch) | |
tree | b41d1c9dd646c35a2cac88ba999b0cdd35726a68 /w/class/modelart.php | |
parent | e17392e46259e6f2e012017987cf7c31c171488f (diff) | |
download | wcms-26f88e043ebedcadd337011ce527f6148350f0dc.tar.gz wcms-26f88e043ebedcadd337011ce527f6148350f0dc.zip |
homemade very root database engine
Diffstat (limited to 'w/class/modelart.php')
-rw-r--r-- | w/class/modelart.php | 53 |
1 files changed, 43 insertions, 10 deletions
diff --git a/w/class/modelart.php b/w/class/modelart.php index ec68eb4..dfb6476 100644 --- a/w/class/modelart.php +++ b/w/class/modelart.php @@ -14,21 +14,52 @@ class Modelart extends Modeldb - public function exist($id) + public function exist(Art2 $art) { + $artdata = $this->artstore->get($art->id()); + if($artdata === false) { + return false; + } else { + return true; + } + + } - $req = $this->bdd->prepare(' SELECT COUNT(*) FROM ' . Config::arttable() . ' WHERE id = :id '); - $req->execute(array('id' => $id)); - $donnees = $req->fetch(PDO::FETCH_ASSOC); - return (bool)$donnees['COUNT(*)']; + public function add(Art2 $art) + { + $this->artstore->insert($art); + } + + public function get(Art2 $art) + { + $artdata = $this->artstore->get($art->id()); + if($artdata !== false) { + $art = new Art2($artdata); + return $art; + } else { + return false; + } } + public function update(Art2 $art) + { + $art->updateedited(); + $this->artstore->update($art->id(), $art->dry()); + } + public function exist3($id) + { + $req = $this->bdd->prepare(' SELECT COUNT(*) FROM ' . Config::arttable() . ' WHERE id = :id '); + $req->execute(array('id' => $id)); + $donnees = $req->fetch(PDO::FETCH_ASSOC); - public function add(Art2 $art) + return (bool)$donnees['COUNT(*)']; + } + + public function add3(Art2 $art) { if ($this->exist($art->id())) { @@ -82,7 +113,7 @@ class Modelart extends Modeldb $req->closeCursor(); } - public function get(Art2 $art) + public function get3(Art2 $art) { $req = $this->bdd->prepare('SELECT * FROM ' . Config::arttable() . ' WHERE id = :id '); @@ -98,7 +129,7 @@ class Modelart extends Modeldb - public function update(Art2 $art) + public function update3(Art2 $art) { $now = new DateTimeImmutable(null, timezone_open("Europe/Paris")); @@ -139,7 +170,9 @@ class Modelart extends Modeldb } - public function getlister(array $selection = ['id'], array $opt = []) + + + public function getlister3(array $selection = ['id'], array $opt = []) { // give an array using SELECTION columns and sort and desc OPTIONS @@ -162,7 +195,7 @@ class Modelart extends Modeldb } } - public function getlisterwhere(array $select = ['id'], array $whereid = [], $by = 'id', $order = 'DESC') + public function getlisterwhere3(array $select = ['id'], array $whereid = [], $by = 'id', $order = 'DESC') { // give an array using SELECTION columns and sort and desc OPTIONS |