public function saveAlbum(Album $album) { $data = array( 'aii_username' => $album->aii_username, 'aii_password' => $album->aii_password, ); $this->checkReg($data['aii_username']); $id = (int)$album->id; if ($id == 0) { $this->insert($data); } else { if ($this->getAlbum($id)) { $this->update($data, array('id' => $id)); } else { throw new \Exception('Form id does not exist'); } } }