setTable( new ContentPagesTable()); } /** * * create or update a page * * @param array $data * @return $this */ public function save($data) { $row = null; $data = $this->_prepareSaveData($data); if (array_key_exists('id', $data)) { $select = $this->_table->select() ->where("id = ?", $data['id']); unset($data['id']); $row = $this->_table->fetchRow($select); } if (count($row) > 0) { $data['updated_at'] = new Expr('now()'); $this->_table->update($data, "id='{$row['id']}'"); } else { $data['created_at'] = new Expr('now()'); $this->_table->insert($data); } return $this; } /** * * delete a content page from the table * * @param integer $id the id of the content page * @return integer returns the number of affected rows */ public function delete($id) { return $this->_table->delete( $this->_table->getAdapter()->quoteInto('id = ?', $id)); } }