public function create($data) { // Action used for POST requests $centre = new Centre(); $centre->exchangeArray($data['centre']); $this->getCentreTable()->saveCentre($centre); $data['centre']['id'] = $centre->id; return new JsonModel($data); }
public function getCentre($id) { $id = (int) $id; $sql = new Sql($this->tableGateway->getAdapter()); $select = $sql->select("centre"); $select->where(array("id" => $id)); $select->columns(array("id", "name", "location" => new Expression("AsWKT(location)"), "post_code", "address", "buses", "tube", "accebility", "accebility_condition", "other_information")); $statement = $sql->prepareStatementForSqlObject($select); $rowset = $statement->execute(); $row = $rowset->current(); if (!$row) { throw new \Exception("Could not find row {$id}"); } $centre = new Centre(); $centre->exchangeArray($row); return $centre; }