本文整理汇总了PHP中DatabaseBase::wasReadOnlyError方法的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseBase::wasReadOnlyError方法的具体用法?PHP DatabaseBase::wasReadOnlyError怎么用?PHP DatabaseBase::wasReadOnlyError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatabaseBase
的用法示例。
在下文中一共展示了DatabaseBase::wasReadOnlyError方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleWriteError
/**
* Handle a DBQueryError which occurred during a write operation.
*/
protected function handleWriteError(DBError $exception)
{
if ($exception instanceof DBConnectionError) {
$this->connFailureTime = time();
$this->connFailureError = $exception;
}
if ($this->db && $this->db->wasReadOnlyError()) {
try {
$this->db->rollback(__METHOD__);
} catch (DBError $e) {
}
}
wfDebugLog('SQLBagOStuff', "DBError: {$exception->getMessage()}");
if ($this->db) {
wfDebug(__METHOD__ . ": ignoring query error\n");
} else {
wfDebug(__METHOD__ . ": ignoring connection error\n");
}
}
示例2: startWrite
public function startWrite($code)
{
if ($this->readOnly) {
return;
}
if (!$code) {
throw new MWException(__METHOD__ . ": Invalid language \"{$code}\"");
}
$this->dbw = wfGetDB(DB_MASTER);
try {
$this->dbw->begin(__METHOD__);
$this->dbw->delete('l10n_cache', array('lc_lang' => $code), __METHOD__);
} catch (DBQueryError $e) {
if ($this->dbw->wasReadOnlyError()) {
$this->readOnly = true;
$this->dbw->rollback(__METHOD__);
return;
} else {
throw $e;
}
}
$this->currentLang = $code;
$this->batch = array();
}
示例3: finishWrite
public function finishWrite()
{
if ($this->readOnly) {
return;
} elseif (is_null($this->currentLang)) {
throw new MWException(__CLASS__ . ': must call startWrite() before finishWrite()');
}
$this->dbw->begin(__METHOD__);
try {
$this->dbw->delete('l10n_cache', array('lc_lang' => $this->currentLang), __METHOD__);
foreach (array_chunk($this->batch, 500) as $rows) {
$this->dbw->insert('l10n_cache', $rows, __METHOD__);
}
$this->writesDone = true;
} catch (DBQueryError $e) {
if ($this->dbw->wasReadOnlyError()) {
$this->readOnly = true;
// just avoid site down time
} else {
throw $e;
}
}
$this->dbw->commit(__METHOD__);
$this->currentLang = null;
$this->batch = array();
}