コード例 #1
0
ファイル: Connector.php プロジェクト: marella/phd
 /**
  * Create a new PDO connection.
  *
  * @param string $dsn
  * @param array  $config
  * @param array  $options
  *
  * @return \PDO
  */
 public function createConnection($dsn, array $config, array $options)
 {
     $username = Arr::get($config, 'username');
     $password = Arr::get($config, 'password');
     try {
         $pdo = new PDO($dsn, $username, $password, $options);
     } catch (Exception $e) {
         $pdo = $this->tryAgainIfCausedByLostConnection($e, $dsn, $username, $password, $options);
     }
     return $pdo;
 }
コード例 #2
0
ファイル: DatabaseManager.php プロジェクト: marella/phd
 /**
  * Get the configuration for a connection.
  *
  * @param string $name
  *
  * @throws \InvalidArgumentException
  *
  * @return array
  */
 protected function getConfig($name)
 {
     $name = $name ?: $this->getDefaultConnection();
     // To get the database connection configuration, we will just pull each of the
     // connection configurations and get the configurations for the given name.
     // If the configuration doesn't exist, we'll throw an exception and bail.
     $connections = $this->config['connections'];
     if (is_null($config = Arr::get($connections, $name))) {
         throw new InvalidArgumentException("Database [{$name}] not configured.");
     }
     return $config;
 }
コード例 #3
0
ファイル: Connection.php プロジェクト: marella/phd
 /**
  * Get an option from the configuration options.
  *
  * @param string $option
  *
  * @return mixed
  */
 public function getConfig($option)
 {
     return Arr::get($this->config, $option);
 }