本文整理汇总了PHP中Illuminate\Database\Connection::getConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::getConfig方法的具体用法?PHP Connection::getConfig怎么用?PHP Connection::getConfig使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Connection
的用法示例。
在下文中一共展示了Connection::getConfig方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compileCreateEncoding
/**
* Append the character set specifications to a command.
*
* @param string $sql
* @param \Illuminate\Database\Connection $connection
* @return string
*/
protected function compileCreateEncoding($sql, Connection $connection)
{
if (!is_null($charset = $connection->getConfig('charset'))) {
$sql .= ' default character set ' . $charset;
}
if (!is_null($collation = $connection->getConfig('collation'))) {
$sql .= ' collate ' . $collation;
}
return $sql;
}
示例2: compileCreateEncoding
/**
* Append the character set specifications to a command.
*
* @param string $sql
* @param \Illuminate\Database\Connection $connection
* @param \Illuminate\Database\Schema\Blueprint $blueprint
* @return string
*/
protected function compileCreateEncoding($sql, Connection $connection, Blueprint $blueprint)
{
if (isset($blueprint->charset)) {
$sql .= ' default character set ' . $blueprint->charset;
} elseif (!is_null($charset = $connection->getConfig('charset'))) {
$sql .= ' default character set ' . $charset;
}
if (isset($blueprint->collation)) {
$sql .= ' collate ' . $blueprint->collation;
} elseif (!is_null($collation = $connection->getConfig('collation'))) {
$sql .= ' collate ' . $collation;
}
return $sql;
}
示例3: 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;
}
示例4: isSqlite
/**
* Return whether or not the current database driver is SQLite.
*
* Useful for avoiding running queries that are not compatible with SQLite.
*
* @return bool
*/
protected function isSqlite()
{
return $this->db->getConfig('driver') == 'sqlite';
}