本文整理汇总了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;
}
示例2: databaseDriver
/**
* Returns current database driver.
*
* @return string
*/
public function databaseDriver()
{
return $this->connection->getDriverName();
}