public getSlave ( boolean $fallbackToMaster = true ) : |
||
$fallbackToMaster | boolean | whether to return a master connection in case there is no slave connection available. |
리턴 | the currently active slave connection. Null is returned if there is slave available and `$fallbackToMaster` is false. |
public function getSlave($fallbackToMaster = true)
{
if (!$this->enableSlaves) {
return $fallbackToMaster ? $this : null;
}
if ($this->_slave === false) {
$this->_slave = $this->openFromPool($this->slaves, $this->slaveConfig);
}
return $this->_slave === null && $fallbackToMaster ? $this : $this->_slave;
}