public function saveMeta(Meta $meta) { $id = (int) $meta->getMetaid(); $row = 0; if ($id > 0) { //var_dump($meta); //exit; $requete = $this->dbGateway->prepare("\r\n UPDATE meta SET meta_key= :key, meta_value= :value WHERE meta_id = :id\r\n ") or die(print_r($this->dbGateway->errors_info())); $requete->bindParam(':value', $meta->getMetavalue(), \PDO::PARAM_STR); $requete->bindParam(':key', $meta->getMetakey(), \PDO::PARAM_STR); $requete->bindParam(':id', $id, \PDO::PARAM_INT); $requete->execute(); $row = $requete->rowCount(); } else { $requete = $this->dbGateway->prepare("INSERT into meta(meta_key, meta_value, rubrique_id) \r\n\t\tvalues(:key, :value, :rubid)") or die(print_r($this->dbGateway->error_info())); $requete->execute(array('key' => $meta->getMetakey(), 'value' => $meta->getMetavalue(), 'rubid' => $meta->getRubriqueId())); $row = $this->dbGateway->lastInsertId(); } return $row; }
function updatemetaajaxAction() { $id = (int) $this->params()->fromRoute('id', 0); $meta = new Meta(); $this->translator = $this->getServiceLocator()->get('translator'); $this->metaDao = new MetaDao(); $request = $this->getRequest(); if ($request->isPost()) { $utils = new Utils(); //$meta->setMetakey($request->getPost()->set('metakey', $utils->stripTags_replaceHtmlChar_trim($request->getPost('metakey'), true, true, true))); //$meta->setMetavalue($request->getPost()->set('metavalue', $utils->stripTags_replaceHtmlChar_trim($request->getPost('metavalue'), true, true, true))); $meta->setMetakey($utils->stripTags_replaceHtmlChar_trim($request->getPost('metakey'), true, true, true)); $meta->setMetavalue($utils->stripTags_replaceHtmlChar_trim($request->getPost('metavalue'), true, true, true)); $meta->setMetaid($id); $meta->setRubriqueid((int) $request->getPost('rubriqueid')); //get number of row inserted $row = $this->metaDao->saveMeta($meta); $result = array(); if ($row == 0 || $row > 1) { $result['error'] = $this->translator->translate("Un problème est survenu, veuillez recommencer"); } else { if ($row == 1) { $result['result'] = "OK"; } } return new JsonModel($result); } }