本文整理匯總了PHP中Illuminate\Database\Connection::getName方法的典型用法代碼示例。如果您正苦於以下問題:PHP Connection::getName方法的具體用法?PHP Connection::getName怎麽用?PHP Connection::getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Database\Connection
的用法示例。
在下文中一共展示了Connection::getName方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: prepare
/**
* Prepare the database connection instance.
*
* @param \Illuminate\Database\Connection $connection
* @return \Illuminate\Database\Connection
*/
protected function prepare(Connection $connection)
{
$connection->setFetchMode($this->app['config']['database.fetch']);
if ($this->app->bound('events')) {
$connection->setEventDispatcher($this->app['events']);
}
// The database connection can also utilize a cache manager instance when cache
// functionality is used on queries, which provides an expressive interface
// to caching both fluent queries and Eloquent queries that are executed.
$app = $this->app;
$connection->setCacheManager(function () use($app) {
return $app['cache'];
});
// We will setup a Closure to resolve the paginator instance on the connection
// since the Paginator isn't used on every request and needs quite a few of
// our dependencies. It'll be more efficient to lazily resolve instances.
$connection->setPaginator(function () use($app) {
return $app['paginator'];
});
// Here we'll set a reconnector callback. This reconnector can be any callable
// so we will set a Closure to reconnect from this manager with the name of
// the connection, which will allow us to reconnect from the connections.
$connection->setReconnector(function ($connection) {
$this->reconnect($connection->getName());
});
return $connection;
}
示例2: __construct
public function __construct(Connection $connection, RepositoryContract $config)
{
$dbconfig = $config->get('database.connections.' . $connection->getName());
$this->dsn = static::parseDSN($dbconfig);
$this->username = $dbconfig['username'];
$this->password = $dbconfig['password'];
}
示例3: generateCacheKey
/**
* Generate the unique cache key for the query.
*
* @return string
*/
public function generateCacheKey()
{
$name = $this->connection->getName();
return md5($name . $this->toSql() . serialize($this->bindings));
}
示例4: prepare
/**
* Prepare the database connection instance.
*
* @param \Illuminate\Database\Connection $connection
* @return \Illuminate\Database\Connection
*/
protected function prepare(Connection $connection)
{
$connection->setFetchMode($this->app['config']['database.fetch']);
if ($this->app->bound('events')) {
$connection->setEventDispatcher($this->app['events']);
}
// Here we'll set a reconnector callback. This reconnector can be any callable
// so we will set a Closure to reconnect from this manager with the name of
// the connection, which will allow us to reconnect from the connections.
$connection->setReconnector(function ($connection) {
$this->reconnect($connection->getName());
});
return $connection;
}
示例5: __construct
/**
* Create a new event instance.
*
* @param \Illuminate\Database\Connection $connection
* @return void
*/
public function __construct($connection)
{
$this->connection = $connection;
$this->connectionName = $connection->getName();
}