aboutsummaryrefslogtreecommitdiff
path: root/w/class/modelart.php
diff options
context:
space:
mode:
Diffstat (limited to 'w/class/modelart.php')
-rw-r--r--w/class/modelart.php53
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