Illuminate\Database\Connection::getDriverName PHP Метод

getDriverName() публичный Метод

Get the PDO driver name.
public getDriverName ( ) : string
Результат string
    public function getDriverName()
    {
        return $this->getConfig('driver');
    }

Usage Example

Пример #1
0
 /**
  * @param \Illuminate\Database\Connection $eloquentConnection
  *
  * @return \DreamFactory\Core\Database\Connection
  * @throws \DreamFactory\Core\Exceptions\InternalServerErrorException
  */
 public static function getLegacyConnection($eloquentConnection)
 {
     if (empty(static::$connection)) {
         $driver = $eloquentConnection->getDriverName();
         if (empty($driver)) {
             throw new InternalServerErrorException('No database driver supplied');
         }
         $connections = config('database.connections');
         if (empty($connections)) {
             throw new InternalServerErrorException('No connections found in database.connections config');
         }
         $configKeys = [];
         foreach ($connections as $name => $connectionConfig) {
             if ($driver === $name || $driver === $connectionConfig['driver'] || $driver === 'dblib' && $name === 'sqlsrv') {
                 $configKeys = array_keys($connectionConfig);
             }
         }
         if (empty($configKeys)) {
             throw new InternalServerErrorException('Unsupported driver - ' . $driver);
         }
         $config = [];
         foreach ($configKeys as $key) {
             $config[$key] = $eloquentConnection->getConfig($key);
         }
         switch ($driver) {
             case 'sqlite':
                 $dsn = $driver . ":" . $config['database'];
                 break;
             case 'mysql':
                 $dsn = static::getMySqlDsn($config);
                 break;
             case 'pgsql':
                 $dsn = static::getPgSqlDsn($config);
                 break;
             case 'sqlsrv':
             case 'dblib':
                 $dsn = static::getSqlSrvDsn($config);
                 break;
             default:
                 throw new InternalServerErrorException('Unsupported driver - ' . $driver);
                 break;
         }
         $config['dsn'] = $dsn;
         static::$connection = ConnectionFactory::createConnection($driver, $config);
     }
     return static::$connection;
 }
All Usage Examples Of Illuminate\Database\Connection::getDriverName