%PDF- %PDF-
Direktori : /var/www/html/bbw/farmaci/kritik-portale/module/Album/src/Album/Model/ |
Current File : /var/www/html/bbw/farmaci/kritik-portale/module/Album/src/Album/Model/AlbumTable.php |
<?php /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * Description of AlbumTable * * @author Florian Koller ( conlabz GmbH ) <florian.koller at conlabz.de> */ namespace Album\Model; use Zend\Db\TableGateway\TableGateway; class AlbumTable { protected $tableGateway; public function __construct(TableGateway $tableGateway) { $this->tableGateway = $tableGateway; } public function fetchAll() { $resultSet = $this->tableGateway->select(); return $resultSet; } public function getAlbum($id) { $id = (int) $id; $rowset = $this->tableGateway->select(array('id' => $id)); $row = $rowset->current(); if (!$row) { throw new \Exception("Could not find row $id"); } return $row; } public function saveAlbum(Album $album) { $data = array( 'artist' => $album->artist, 'title' => $album->title, ); $id = (int) $album->id; if ($id == 0) { $this->tableGateway->insert($data); echo "TEST"; } else { if ($this->getAlbum($id)) { $this->tableGateway->update($data, array('id' => $id)); } else { throw new \Exception('Album id does not exist'); } } } public function deleteAlbum($id) { $this->tableGateway->delete(array('id' => (int) $id)); } }