当前位置: 首页>>代码示例>>PHP>>正文


PHP Connection::getDriverName方法代码示例

本文整理汇总了PHP中Illuminate\Database\Connection::getDriverName方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::getDriverName方法的具体用法?PHP Connection::getDriverName怎么用?PHP Connection::getDriverName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Database\Connection的用法示例。


在下文中一共展示了Connection::getDriverName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getLegacyConnection

 /**
  * @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;
 }
开发者ID:df-arif,项目名称:df-core,代码行数:53,代码来源:ConnectionAdapter.php

示例2: databaseDriver

 /**
  * Returns current database driver.
  *
  * @return string
  */
 public function databaseDriver()
 {
     return $this->connection->getDriverName();
 }
开发者ID:GHFernando,项目名称:laravel-datatables,代码行数:9,代码来源:BaseEngine.php


注:本文中的Illuminate\Database\Connection::getDriverName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。