public function delete() { $p = Person::findFirst($this->getPersonId()); $s = Status::findFirst(array('name' => 'deleted')); $delete = $p->update(array('status_id' => $s->getId(), 'updated_at' => new \Datetime('now', new \DateTimeZone('UTC')))); return $delete ? true : false; }
/** * @param integer $statusId */ public function delete($statusId) { if (!$this->application->request->isDelete()) { throw new Exception('Method not allowed', 405); } if (!$this->isAllowed()) { throw new Exception('User not authorized', 401); } $status = Status::findFirst($statusId); if (!$status) { throw new Exception('Status not found', 404); } if (!$status->delete()) { throw new Exception('Status not deleted', 500); } return array('code' => 204, 'content' => 'Status instance deleted'); }
/** * @param integer $statusName */ public function getList($statusName) { if (!$this->application->request->isGet()) { throw new Exception('Method not allowed', 405); } $statuses = Status::find(); $statusesArr = $statuses->toArray('name'); if (!in_array($statusName, $statusesArr)) { throw new Exception('Invalid parameter', 409); } $status = Status::findFirst(array('conditions' => 'name = :name:', 'bind' => array('name' => $statusName))); $seasons = Season::find(array('conditions' => 'status_id = :id:', 'bind' => array('id' => $status->getId()), 'order' => 'number ASC', 'group' => 'program_id')); if (!$seasons) { throw new Exception('Query not executed', 500); } if ($seasons->count() == 0) { return array('code' => 204, 'content' => 'No matching Season instance found'); } return array('code' => 200, 'content' => $seasons->toArray()); }
/** * @param text $statusName */ public function getList($statusName) { if (!$this->application->request->isGet()) { throw new Exception('Method not allowed', 405); } $statuses = Status::find(); $sArr = $statuses->toArray('name'); if (!in_array($st, $sArr)) { throw new Exception('Invalid parameter', 409); } $status = Status::findFirst(array('conditions' => "name = :name:", 'bind' => array('name' => $statusName))); $lyrics = Lyrics::find(array('conditions' => "status_id = :id:", 'bind' => array('id' => $status->getId()), 'order' => 'updated_at DESC')); if (!lyrics) { throw new Exception('Query not executed', 500); } if ($lyrics->count() == 0) { return array('code' => 204, 'content' => 'No lyrics instance found'); } return array('code' => 200, 'content' => $lyrics->toArray()); }
/** * @param text $statusName */ public function getList($statusName) { if (!$this->application->request->isGet()) { throw new Exception('Method not allowed', 405); } $statuses = Status::find(); $sArr = $statuses->toArray('name'); if (!in_array($statusName, $sArr)) { throw new Exception('Invalid parameter', 405); } $status = Status::findFirst(array('conditions' => "name = :name:", 'bind' => array('name' => $statusName))); $mangas = Manga::find(array('conditions' => "status_id = :id:", 'bind' => array('id' => $status->getId()), 'order' => 'name ASC')); if (!$mangas) { throw new Exception('Query not executed', 500); } if ($mangas->count() == 0) { return array('code' => 204, 'content' => 'No matching Manga instance found'); } $output = array(); foreach ($mangas as $m) { $mArr = $manga->toArray(); $mgNames = array(); foreach ($mArr['genres'] as $mg) { $mg = MangaGenre::findFirst($mg); array_push($mgNames, $mg->getName()); } $mArr['genres'] = $mgNames; array_push($output, $mArr); } return array('code' => 200, 'content' => $output); }
/** * @param text $statusName */ public function getList($statusName) { if (!$this->application->request->isGet()) { throw new Exception('Method not allowed', 405); } $statuses = Status::find(); $statNames = $statuses->toArray('name'); if (!in_array($statuses, $statNames)) { throw new Exception('Invalid parameter', 409); } $status = Status::findFirst(array('conditions' => "name = :name:", 'bind' => array('name' => $statusName))); $MCs = MangaCharacter::find(array('conditions' => "status_id = :id:", 'bind' => array('id' => $status->getId()))); if (!$MCs) { throw new Exception('Query not executed', 500); } if ($MCs->count() == 0) { return array('code' => 204, 'content' => 'No matching MangaCharacter instance found'); } $output = array(); foreach ($MCs as $mc) { $p = Person::findFirst($mc->getPersonId()); $pArr = $p->toArray(); unset($pArr['id']); array_push($output, array_merge($mc->toArray(), $pArr)); } return array('code' => 200, 'content' => $output); }