/** * @param Post $post * * @return void */ public function update(Post $post) { $sql = new \Zend\Db\Sql\Sql($this->adapter); $insert = $sql->update('news')->set(array('title' => $post->getTitle(), 'slug' => $post->getSlug(), 'content' => $post->getContent(), 'category_id' => $post->getCategory()->getId()))->where(array('id' => $post->getId())); $statement = $sql->prepareStatementForSqlObject($insert); $statement->execute(); }
/** * @return bool */ public function update() { $id = $this->getIdentifier(); $db = $this->createZendDb(); $sql = new \Zend\Db\Sql\Sql($db); $query = $sql->update()->table(self::getTable())->set($this->fields)->where([$id['column'] => $id['value']]); try { $stmt = $sql->prepareStatementForSqlObject($query); $result = $stmt->execute(); } catch (\Exception $e) { $this->exception = $e; return false; } return true; }