本文整理匯總了PHP中Fisharebest\Webtrees\Database::rollBack方法的典型用法代碼示例。如果您正苦於以下問題:PHP Database::rollBack方法的具體用法?PHP Database::rollBack怎麽用?PHP Database::rollBack使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Fisharebest\Webtrees\Database
的用法示例。
在下文中一共展示了Database::rollBack方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: REPLACE
$first_time = false;
// Re-fetch the data, now that we have performed character set conversion.
$data = Database::prepare("SELECT gedcom_chunk_id, REPLACE(chunk_data, '\r', '\n') AS chunk_data" . " FROM `##gedcom_chunk`" . " WHERE gedcom_chunk_id=?")->execute(array($data->gedcom_chunk_id))->fetchOneRow();
}
if (!$data) {
break;
}
try {
// Import all the records in this chunk of data
foreach (preg_split('/\\n+(?=0)/', $data->chunk_data) as $rec) {
FunctionsImport::importRecord($rec, $tree, false);
}
// Mark the chunk as imported
Database::prepare("UPDATE `##gedcom_chunk` SET imported=TRUE WHERE gedcom_chunk_id=?")->execute(array($data->gedcom_chunk_id));
} catch (PDOException $ex) {
Database::rollBack();
if ($ex->getCode() === '40001') {
// "SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction"
// The documentation says that if you get this error, wait and try again.....
$controller->addInlineJavascript('jQuery("#import' . $gedcom_id . '").load("import.php?gedcom_id=' . $gedcom_id . '&u=' . uniqid() . '");');
} else {
// A fatal error. Nothing we can do?
echo '<span class="error">', $ex->getMessage(), '</span>';
$controller->addInlineJavascript('jQuery("#actions' . $gedcom_id . '").removeClass("hidden");');
}
return;
}
}
Database::commit();
// Reload.....
// Use uniqid() to prevent jQuery caching the previous response.