本文整理汇总了PHP中Fisharebest\Webtrees\Database::rollback方法的典型用法代码示例。如果您正苦于以下问题:PHP Database::rollback方法的具体用法?PHP Database::rollback怎么用?PHP Database::rollback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fisharebest\Webtrees\Database
的用法示例。
在下文中一共展示了Database::rollback方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteTask
/**
* {inhericDoc}
* @see \MyArtJaub\Webtrees\Module\AdminTasks\Model\TaskProviderInterface::deleteTask()
*/
public function deleteTask($task_name)
{
try {
Database::beginTransaction();
Database::prepare('DELETE FROM `##maj_admintasks` WHERE majat_name= :task_name')->execute(array('task_name' => $task_name));
Database::prepare('DELETE FROM `##gedcom_setting` WHERE setting_name LIKE :setting_name')->execute(array('setting_name' => 'MAJ_AT_' . $task_name . '%'));
Database::commit();
Log::addConfigurationLog('Admin Task ' . $task_name . ' has been deleted from disk - deleting it from DB');
return true;
} catch (\Exception $ex) {
Database::rollback();
Log::addErrorLog('An error occurred while deleting Admin Task ' . $task_name . '. Exception: ' . $ex->getMessage());
return false;
}
}
示例2: updateGeoAnalysis
/**
* Update a geodispersion analysis in the database, in transactional manner.
* When successful, returns the updated GeoAnalysis object
*
* @param GeoAnalysis $ga
* @return GeoAnalysis
*/
public function updateGeoAnalysis(GeoAnalysis $ga)
{
try {
Database::beginTransaction();
Database::prepare('UPDATE `##maj_geodispersion`' . ' SET majgd_descr = :description,' . ' majgd_sublevel = :analysis_level,' . ' majgd_map = :map,' . ' majgd_toplevel = :map_top_level,' . ' majgd_useflagsgen = :use_flags,' . ' majgd_detailsgen = :gen_details' . ' WHERE majgd_file = :gedcom_id AND majgd_id = :ga_id')->execute(array('gedcom_id' => $this->tree->getTreeId(), 'ga_id' => $ga->getId(), 'description' => $ga->getTitle(), 'analysis_level' => $ga->getAnalysisLevel(), 'use_flags' => $ga->getOptions() && $ga->getOptions()->isUsingFlags() ? 'yes' : 'no', 'gen_details' => $ga->getOptions() ? $ga->getOptions()->getMaxDetailsInGen() : 0, 'map' => $ga->hasMap() ? $ga->getOptions()->getMap()->getFileName() : null, 'map_top_level' => $ga->hasMap() ? $ga->getOptions()->getMapLevel() : -100));
$ga = $this->getGeoAnalysis($ga->getId(), false);
Database::commit();
} catch (\Exception $ex) {
Database::rollback();
Log::addErrorLog('The Geo Analysis ID “' . $ga->getId() . '” failed to be updated. Transaction rollbacked. Exception: ' . $ex->getMessage());
$ga = null;
}
return $ga;
}