connect() 공개 메소드

{@inheritDoc}
public connect ( $connectionName = null )
 /**
  * @param MasterSlaveConnection $connection
  * @return Success|Failure
  */
 private function checkMasterSlaveConnection(MasterSlaveConnection $connection)
 {
     // TODO Check all slaves, instead of random one if possible.
     $connection->connect('slave');
     $isSlaveConnected = $connection->ping();
     $connection->connect('master');
     $isMasterConnected = $connection->ping();
     $data = ['slave' => $isSlaveConnected ? 'connected' : 'not connected', 'master' => $isMasterConnected ? 'connected' : 'not connected'];
     if ($isMasterConnected && $isSlaveConnected) {
         return new Success(get_class($connection), $data);
     }
     return new Failure(get_class($connection), $data);
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function connect($connectionName = null)
 {
     try {
         return parent::connect($connectionName);
     } catch (DBALException $e) {
         if ($this->_eventManager->hasListeners('failConnect')) {
             $eventArgs = new FailedConnectionEvent($this, $e);
             $this->_eventManager->dispatchEvent('failConnect', $eventArgs);
         }
     }
 }