X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=module%2FGalerie%2Fsrc%2FGalerie%2FModel%2FGalerieATable.php;fp=module%2FGalerie%2Fsrc%2FGalerie%2FModel%2FGalerieATable.php;h=a37ce61acda6106987d52f303a48c73bc0639014;hb=85889014266a202a509f6042a4ebe95d25533170;hp=0000000000000000000000000000000000000000;hpb=48e9ad9d4303b9d6df7e52735426ef7070a0cc59;p=zf2.biz%2Fgalerie.git diff --git a/module/Galerie/src/Galerie/Model/GalerieATable.php b/module/Galerie/src/Galerie/Model/GalerieATable.php new file mode 100644 index 0000000..a37ce61 --- /dev/null +++ b/module/Galerie/src/Galerie/Model/GalerieATable.php @@ -0,0 +1,81 @@ +adapter = $adapter; + + // Utilisation du patron de conception Prototype + // pour la création des objets ResultSet + $this->resultSetPrototype = new ResultSet(); + $this->resultSetPrototype->setArrayObjectPrototype( + new GalerieA() + ); + + // Initialisation du gestionnaire + $this->initialize(); + } + + public function fetchAll() + { + return $this->select(); + } + + public function getGalerie($id) + { + if ($id === null) { + $row = null; + } else { + $row = $this->select(array( + 'id' => (int) $id, + ))->current(); + } + if (!$row) { + throw new \Exception("cannot get row $id in table 'galerie'"); + } + return $row; + } + +/* public saveGalerie(GalerieA $galerie) + { + if ($galerie->id === null) { + $this->insert( + array( + 'name' => $galerie->name, + 'description' => $galerie->description, + ) + ); + } elseif ($this->getGalerie($galerie->id)) { + $this->update( + array( + 'name' => $galerie->name, + 'description' => $galerie->description, + ), + array( + 'id' => $galerie->id, + ) + ); + } else { + throw new \Exception("cannot update row $galerie->id in table 'galerie'"); + } + } +*/ + public function deleteGalerie($id) + { + $this->delete(array( + 'id' => (int) $id + ) + ); + } + +}