本文整理汇总了PHP中DatabaseBase::masterPosWait方法的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseBase::masterPosWait方法的具体用法?PHP DatabaseBase::masterPosWait怎么用?PHP DatabaseBase::masterPosWait使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatabaseBase
的用法示例。
在下文中一共展示了DatabaseBase::masterPosWait方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: masterPosWait
/**
* Wait for the slave to catch up to a given master position.
* @TODO: return values for this and base class are rubbish
*
* @param $pos DBMasterPos object
* @param $timeout Integer: the maximum number of seconds to wait for synchronisation
* @return bool|string
*/
function masterPosWait( DBMasterPos $pos, $timeout ) {
if ( $this->lastKnownSlavePos && $this->lastKnownSlavePos->hasReached( $pos ) ) {
return '0'; // http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html
}
wfProfileIn( __METHOD__ );
# Commit any open transactions
$this->commit( __METHOD__, 'flush' );
if ( !is_null( $this->mFakeSlaveLag ) ) {
$status = parent::masterPosWait( $pos, $timeout );
wfProfileOut( __METHOD__ );
return $status;
}
# Call doQuery() directly, to avoid opening a transaction if DBO_TRX is set
$encFile = $this->addQuotes( $pos->file );
$encPos = intval( $pos->pos );
$sql = "SELECT MASTER_POS_WAIT($encFile, $encPos, $timeout)";
$res = $this->doQuery( $sql );
$status = false;
if ( $res && $row = $this->fetchRow( $res ) ) {
$status = $row[0]; // can be NULL, -1, or 0+ per the MySQL manual
if ( ctype_digit( $status ) ) { // success
$this->lastKnownSlavePos = $pos;
}
}
wfProfileOut( __METHOD__ );
return $status;
}
示例2: masterPosWait
/**
* Wait for the slave to catch up to a given master position.
*
* @param $pos DBMasterPos object
* @param $timeout Integer: the maximum number of seconds to wait for synchronisation
*/
function masterPosWait(DBMasterPos $pos, $timeout)
{
$fname = 'DatabaseBase::masterPosWait';
wfProfileIn($fname);
# Commit any open transactions
if ($this->mTrxLevel) {
$this->commit();
}
if (!is_null($this->mFakeSlaveLag)) {
$status = parent::masterPosWait($pos, $timeout);
wfProfileOut($fname);
return $status;
}
# Call doQuery() directly, to avoid opening a transaction if DBO_TRX is set
$encFile = $this->addQuotes($pos->file);
$encPos = intval($pos->pos);
$sql = "SELECT MASTER_POS_WAIT({$encFile}, {$encPos}, {$timeout})";
$res = $this->doQuery($sql);
if ($res && ($row = $this->fetchRow($res))) {
wfProfileOut($fname);
return $row[0];
} else {
wfProfileOut($fname);
return false;
}
}