public function getAssessByCriteria(FetchAssessByCriteria $criteria) { $where = array(); if ($criteria->getKind() != NULL) { $where['kind'] = $criteria->getKind(); } if ($criteria->getType() != NULL) { $where['type'] = $criteria->getType(); } if (!empty($where)) { return $this->select($where); } else { return $this->fetchAll(); } }
public function indexAction() { $criteria = new FetchAssessByCriteria(); $criteria->setKind((int) $this->params()->fromRoute('kind', NULL)); $criteria->setType((int) $this->params()->fromRoute('type', NULL)); echo "kind:" . (int) $this->params()->fromRoute('kind', NULL); $items = $this->getAssessTable()->getAssessByCriteria($criteria); foreach ($items as $item) { $temp_data = $item->get_data(); if (is_numeric($item->time_of_purchase)) { $temp_data['time_purchase_date'] = date("Y-m-d", $item->time_of_purchase); } $result[] = $temp_data; } $final_arr = ["status" => true, "result" => $result]; // var_dump($final_arr); // return $this->getResponse()->setContent(Json::encode($final_arr)); }