X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=module%2FGalerie%2Fsrc%2FGalerie%2FModel%2FGalerieCTable.php;fp=module%2FGalerie%2Fsrc%2FGalerie%2FModel%2FGalerieCTable.php;h=92dd6ba1c1d6707455e6d461f2836906857d79b0;hb=8c980b267fd16adb7860789136a38ee6617f5738;hp=0000000000000000000000000000000000000000;hpb=62468b549ae08763d2206b2400486519a04ab17b;p=zf2.biz%2Fgalerie.git diff --git a/module/Galerie/src/Galerie/Model/GalerieCTable.php b/module/Galerie/src/Galerie/Model/GalerieCTable.php new file mode 100644 index 0000000..92dd6ba --- /dev/null +++ b/module/Galerie/src/Galerie/Model/GalerieCTable.php @@ -0,0 +1,73 @@ +adapter = $adapter; + + // Utilisation du patron de conception Prototype + // pour la création des objets ResultSet + $this->resultSetPrototype = new ResultSet(); + $this->resultSetPrototype->setArrayObjectPrototype( + new GalerieC() + ); + + // 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 function saveGalerie(GalerieC $galerie) + { + if ($galerie->id === null) { + $this->insert( + $galerie->toUpdatableArray() + ); + } elseif ($this->getGalerie($galerie->id)) { + $this->update( + $galerie->toUpdatableArray(), + $galerie->toPrimaryArray() + ); + } else { + throw new \Exception("cannot update row {$galerie->id} in table 'galerie'"); + } + } + + public function deleteGalerie($id) + { + $this->delete(array( + 'id' => (int) $id + ) + ); + } + +}