/** * @param Application_Model_Bookmark $model video info */ public function save(Application_Model_Bookmark $model) { $data = $model->toArray(); unset($data['id']); if ($model->isNew()) { $id = $this->getDbTable()->insert($data); $model->setId($id); } else { $this->getDbTable()->update($data, array('id = ?' => $model->getId())); } }
/** * Restore backupped videos * This is not a trigger of plugin API. It's called by Backupper plugin */ function restoreItems($items) { $models = Application_Model_BookmarksMapper::i()->fetchAll(); // cleaning up all shares foreach ($models as $model) { Application_Model_BookmarksMapper::i()->delete($model); } foreach (@$items['pages'] as $modelInfo) { $model = new Application_Model_Bookmark(); $model->setOptions($modelInfo); $model->setId(false); // i don't set id, or db adapter will try to update old data that i cleaned Application_Model_BookmarksMapper::i()->save($model); } return X_Env::_('p_bookmarks_backupper_restoreditems', count($items['pages'])); }