当前位置: 首页>>代码示例>>PHP>>正文


PHP DatabaseBase::masterPosWait方法代码示例

本文整理汇总了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;
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:40,代码来源:DatabaseMysqlBase.php

示例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;
     }
 }
开发者ID:namrenni,项目名称:mediawiki,代码行数:32,代码来源:DatabaseMysql.php


注:本文中的DatabaseBase::masterPosWait方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。