public function getReadConnection(AdapterInterface $adapter = null)
    {
        if ($this->writeConnection && $this->writeConnection->inTransaction()) {
            return $this->writeConnection;
        }

        if ($this->isForceMasterConnection()) {
            return $this->getWriteConnection($adapter);
        }
        if (null === $this->readConnection) {
            if (null === $this->readConfiguration) {
                $this->readConnection = $this->getWriteConnection($adapter);
            } else {
                $keys = array_keys($this->readConfiguration);
                $key = $keys[mt_rand(0, count($keys) - 1)];
                $configuration = $this->readConfiguration[$key];
                $this->readConnection = ConnectionFactory::create($configuration, $adapter);
                $this->readConnection->setName($this->getName());
            }
        }

        return $this->readConnection;
    }
public function getReadConnection(AdapterInterface $adapter = null)
    {
        if ($this->writeConnection && $this->writeConnection->inTransaction()) {
            return $this->writeConnection;
        }

        if ($this->isForceMasterConnection()) {
            return $this->getWriteConnection($adapter);
        }
        if (null === $this->readConnection) {
            if (null === $this->readConfiguration) {
                $this->readConnection = $this->getWriteConnection($adapter);
            } else {
                $keys = array_keys($this->readConfiguration);
                $key = $keys[mt_rand(0, count($keys) - 1)];
                $configuration = $this->readConfiguration[$key];
                $this->readConnection = ConnectionFactory::create($configuration, $adapter);
                $this->readConnection->setName($this->getName());
            }
        }

        return $this->readConnection;
    }
public function getReadConnection ( AdapterInterface $ adapter = null ) { if ( $ this -> writeConnection && $ this -> writeConnection -> inTransaction ( ) ) { return $ this -> writeConnection ; } if ( $ this -> isForceMasterConnection ( ) ) { return $ this -> getWriteConnection ( $ adapter ) ; } if ( null === $ this -> readConnection ) { if ( null === $ this -> readConfiguration ) { $ this -> readConnection = $ this -> getWriteConnection ( $ adapter ) ; } else { $ keys = array_keys ( $ this -> readConfiguration ) ; $ key = $ keys [ mt_rand ( 0 , count ( $ keys ) - 1 ) ] ; $ configuration = $ this -> readConfiguration [ $ key ] ; $ this -> readConnection = ConnectionFactory :: create ( $ configuration , $ adapter ) ; $ this -> readConnection -> setName ( $ this -> getName ( ) ) ; } } return $ this -> readConnection ; }
Get a slave connection.

If no slave connection exist yet, choose one configuration randomly in the
read configuration to open it.

@param \Propel\Runtime\Adapter\AdapterInterface $adapter

@return \Propel\Runtime\Connection\ConnectionInterface
Get a slave connection .