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


PHP LoadBalancer::getConnection方法代码示例

本文整理汇总了PHP中LoadBalancer::getConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP LoadBalancer::getConnection方法的具体用法?PHP LoadBalancer::getConnection怎么用?PHP LoadBalancer::getConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LoadBalancer的用法示例。


在下文中一共展示了LoadBalancer::getConnection方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: list

 function __call($name, array $arguments)
 {
     if ($this->conn === null) {
         list($db, $groups, $wiki) = $this->params;
         $this->conn = $this->lb->getConnection($db, $groups, $wiki);
     }
     return call_user_func_array(array($this->conn, $name), $arguments);
 }
开发者ID:junjiemars,项目名称:mediawiki,代码行数:8,代码来源:DBConnRef.php

示例2: clear

 /**
  * Clears the list of sites stored in the database.
  *
  * @see SiteStore::clear()
  *
  * @return bool Success
  */
 public function clear()
 {
     $dbw = $this->dbLoadBalancer->getConnection(DB_MASTER);
     $dbw->startAtomic(__METHOD__);
     $ok = $dbw->delete('sites', '*', __METHOD__);
     $ok = $dbw->delete('site_identifiers', '*', __METHOD__) && $ok;
     $dbw->endAtomic(__METHOD__);
     $this->reset();
     return $ok;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:17,代码来源:DBSiteStore.php

示例3: getDB

 /**
  * @return DatabaseBase
  */
 protected function getDB()
 {
     if (!isset($this->db)) {
         # If server connection info was given, use that
         if ($this->serverInfo) {
             $this->lb = new LoadBalancer(array('servers' => array($this->serverInfo)));
             $this->db = $this->lb->getConnection(DB_MASTER);
             $this->db->clearFlag(DBO_TRX);
         } else {
             # We must keep a separate connection to MySQL in order to avoid deadlocks
             # However, SQLite has an opposite behaviour.
             # @todo Investigate behaviour for other databases
             if (wfGetDB(DB_MASTER)->getType() == 'sqlite') {
                 $this->db = wfGetDB(DB_MASTER);
             } else {
                 $this->lb = wfGetLBFactory()->newMainLB();
                 $this->db = $this->lb->getConnection(DB_MASTER);
                 $this->db->clearFlag(DBO_TRX);
             }
         }
     }
     return $this->db;
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:26,代码来源:SqlBagOStuff.php

示例4: getDB

	/**
	 * Get a connection to the specified database
	 *
	 * @param $serverIndex integer
	 * @return DatabaseBase
	 */
	protected function getDB( $serverIndex ) {
		global $wgDebugDBTransactions;

		if ( !isset( $this->conns[$serverIndex] ) ) {
			if ( $serverIndex >= $this->numServers ) {
				throw new MWException( __METHOD__ . ": Invalid server index \"$serverIndex\"" );
			}

			# Don't keep timing out trying to connect for each call if the DB is down
			if ( isset( $this->connFailureErrors[$serverIndex] )
				&& ( time() - $this->connFailureTimes[$serverIndex] ) < 60 )
			{
				throw $this->connFailureErrors[$serverIndex];
			}

			# If server connection info was given, use that
			if ( $this->serverInfos ) {
				if ( $wgDebugDBTransactions ) {
					wfDebug( "Using provided serverInfo for SqlBagOStuff\n" );
				}
				$info = $this->serverInfos[$serverIndex];
				$type = isset( $info['type'] ) ? $info['type'] : 'mysql';
				$host = isset( $info['host'] ) ? $info['host'] : '[unknown]';
				wfDebug( __CLASS__ . ": connecting to $host\n" );
				$db = DatabaseBase::factory( $type, $info );
				$db->clearFlag( DBO_TRX );
			} else {
				/*
				 * We must keep a separate connection to MySQL in order to avoid deadlocks
				 * However, SQLite has an opposite behavior. And PostgreSQL needs to know
				 * if we are in transaction or no
				 */
				if ( wfGetDB( DB_MASTER )->getType() == 'mysql' ) {
					$this->lb = wfGetLBFactory()->newMainLB();
					$db = $this->lb->getConnection( DB_MASTER );
					$db->clearFlag( DBO_TRX ); // auto-commit mode
				} else {
					$db = wfGetDB( DB_MASTER );
				}
			}
			if ( $wgDebugDBTransactions ) {
				wfDebug( sprintf( "Connection %s will be used for SqlBagOStuff\n", $db ) );
			}
			$this->conns[$serverIndex] = $db;
		}

		return $this->conns[$serverIndex];
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:54,代码来源:SqlBagOStuff.php

示例5: getDB

 /**
  * Get a connection to the specified database
  *
  * @param int $serverIndex
  * @return IDatabase
  * @throws MWException
  */
 protected function getDB($serverIndex)
 {
     if (!isset($this->conns[$serverIndex])) {
         if ($serverIndex >= $this->numServers) {
             throw new MWException(__METHOD__ . ": Invalid server index \"{$serverIndex}\"");
         }
         # Don't keep timing out trying to connect for each call if the DB is down
         if (isset($this->connFailureErrors[$serverIndex]) && time() - $this->connFailureTimes[$serverIndex] < 60) {
             throw $this->connFailureErrors[$serverIndex];
         }
         # If server connection info was given, use that
         if ($this->serverInfos) {
             $info = $this->serverInfos[$serverIndex];
             $type = isset($info['type']) ? $info['type'] : 'mysql';
             $host = isset($info['host']) ? $info['host'] : '[unknown]';
             $this->logger->debug(__CLASS__ . ": connecting to {$host}");
             // Use a blank trx profiler to ignore expections as this is a cache
             $info['trxProfiler'] = new TransactionProfiler();
             $db = DatabaseBase::factory($type, $info);
             $db->clearFlag(DBO_TRX);
         } else {
             /*
              * We must keep a separate connection to MySQL in order to avoid deadlocks
              * However, SQLite has an opposite behavior. And PostgreSQL needs to know
              * if we are in transaction or no
              */
             $index = $this->slaveOnly ? DB_SLAVE : DB_MASTER;
             if (wfGetDB($index)->getType() == 'mysql') {
                 $this->lb = wfGetLBFactory()->newMainLB();
                 $db = $this->lb->getConnection($index);
                 $db->clearFlag(DBO_TRX);
                 // auto-commit mode
             } else {
                 $db = wfGetDB($index);
             }
         }
         $this->logger->debug(sprintf("Connection %s will be used for SqlBagOStuff", $db));
         $this->conns[$serverIndex] = $db;
     }
     return $this->conns[$serverIndex];
 }
开发者ID:rrameshs,项目名称:mediawiki,代码行数:48,代码来源:SqlBagOStuff.php

示例6: getDB

 /**
  * @return DatabaseBase
  */
 protected function getDB()
 {
     global $wgDebugDBTransactions;
     # Don't keep timing out trying to connect for each call if the DB is down
     if ($this->connFailureError && time() - $this->connFailureTime < 60) {
         throw $this->connFailureError;
     }
     if (!isset($this->db)) {
         # If server connection info was given, use that
         if ($this->serverInfo) {
             if ($wgDebugDBTransactions) {
                 wfDebug(sprintf("Using provided serverInfo for SqlBagOStuff\n"));
             }
             $this->lb = new LoadBalancer(array('servers' => array($this->serverInfo)));
             $this->db = $this->lb->getConnection(DB_MASTER);
             $this->db->clearFlag(DBO_TRX);
         } else {
             /*
              * We must keep a separate connection to MySQL in order to avoid deadlocks
              * However, SQLite has an opposite behaviour. And PostgreSQL needs to know
              * if we are in transaction or no
              */
             if (wfGetDB(DB_MASTER)->getType() == 'mysql') {
                 $this->lb = wfGetLBFactory()->newMainLB();
                 $this->db = $this->lb->getConnection(DB_MASTER);
                 $this->db->clearFlag(DBO_TRX);
                 // auto-commit mode
             } else {
                 $this->db = wfGetDB(DB_MASTER);
             }
         }
         if ($wgDebugDBTransactions) {
             wfDebug(sprintf("Connection %s will be used for SqlBagOStuff\n", $this->db));
         }
     }
     return $this->db;
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:40,代码来源:SqlBagOStuff.php

示例7: getConnection

 /**
  * @param int $slaveOrMaster DB_MASTER or DB_SLAVE
  *
  * @return DatabaseBase
  * @throws MWException
  */
 private function getConnection($slaveOrMaster)
 {
     return $this->loadBalancer->getConnection($slaveOrMaster, ['watchlist']);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:10,代码来源:WatchedItemStore.php


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