• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/data/connectionpool.php
  • Класс: BitrixMainDataConnectionPool
  • Вызов: ConnectionPool::getSlaveConnection
public function getSlaveConnection($sql)
{
	if($this->masterOnly > 0)
	{
		//We requested to process all queries
		//by master connection
	}
	elseif($this->slavePossible)
	{
		$isSelect = preg_match('/^s*(select|show)/i', $sql) && !preg_match('/get_lock/i', $sql);
		if(!$isSelect && $this->ignoreDml <= 0)
		{
			$this->slavePossible = false;
		}

		if($isSelect)
		{
			if($this->slaveConnection === null)
			{
				$this->useMasterOnly(true);

				$this->slaveConnection = $this->createSlaveConnection();

				$this->useMasterOnly(false);
			}

			if(is_object($this->slaveConnection))
			{
				return $this->slaveConnection;
			}
		}
	}
	return null;
}