/** * * @param Application_Model_Property $property * @return type */ public function save(Application_Model_Property $property) { $data = array('reference_no' => $property->getReference_no(), 'title' => $property->getTitle(), 'text' => $property->getText(), 'disposition_id' => $property->getDisposition_id(), 'area' => $property->getArea(), 'floor' => $property->getFloor(), 'lift' => $property->getLift(), 'cellar' => $property->getCellar(), 'balcony' => $property->getBalcony(), 'location_id' => $property->getLocation_id(), 'price' => $property->getPrice(), 'created_on' => date('Y-m-d H-i-s'), 'street' => $property->getStreet(), 'property_build_id' => $property->getProperty_build_id(), 'terace' => $property->getTerace(), 'loggia' => $property->getLoggia(), 'garden' => $property->getGarden(), 'garage' => $property->getGarage(), 'parking_place' => $property->getParking_place()); if (null === ($id = $property->getId())) { unset($data['id']); return $this->getDbTable()->insert($data); } else { $this->getDbTable()->update($data, array('id = ?' => $id)); return $id; } }
public function saveFormAction() { $form = new Application_Form_PropertyForm(); $request = $this->getRequest(); $form->populate($request->getParams()); $this->view->form = $form; if ($this->getRequest()->isPost()) { if ($form->isValid($_POST)) { $values = new Application_Model_Property($form->getValues()); $mapper = new Application_Model_PropertyMapper(); $values->setArea(str_replace(",", ".", $values->getArea())); $values->setPrice(str_replace(",", ".", $values->getPrice())); $newId = $mapper->save($values); $this->_redirect("/property/detail/property/" . $newId); return; } } $this->renderScript("property/add.phtml"); }