示例#1
0
 /**
  *
  * @param \Music\Model\Artist $artist
  * @throws \Exception
  */
 public function saveArtist(Artist $artist)
 {
     $data = array('full_name' => $artist->getFullName(), 'year_found' => $artist->getYearFound(), 'origin' => $artist->getOrigin(), 'createdby' => $this->id);
     $artist_id = (int) $artist->getArtistId();
     if ($artist_id == 0) {
         $this->tableGateway->insert($data);
     } else {
         if ($this->getArtist($artist_id)) {
             //\Zend\Debug\Debug::dump($artist_id);
             $this->tableGateway->update($data, array('artist_id' => $artist_id));
         } else {
             throw new \Exception('Form id does not exist');
         }
     }
 }