本文整理汇总了PHP中Illuminate\Database\ConnectionResolverInterface::connection方法的典型用法代码示例。如果您正苦于以下问题:PHP ConnectionResolverInterface::connection方法的具体用法?PHP ConnectionResolverInterface::connection怎么用?PHP ConnectionResolverInterface::connection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\ConnectionResolverInterface
的用法示例。
在下文中一共展示了ConnectionResolverInterface::connection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fire
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
$name = $this->input->getOption('database');
$total = $this->seeder->seed($this->resolver->connection($name), $this->path);
if ($total == 0) {
$this->info('Nothing to seed.');
}
}
示例2: handle
/**
* @param Request $request
* @param Closure $next
* @return mixed
* @throws \Exception
*/
public function handle(Request $request, Closure $next)
{
$this->connectionResolver->connection()->beginTransaction();
try {
$response = $next($request);
} catch (\Exception $e) {
$this->connectionResolver->connection()->rollBack();
throw $e;
}
$this->connectionResolver->connection()->commit();
return $response;
}
示例3: __construct
/**
* connects the database, saves SQL-Connection, database-name and prefix
* @param ConnectionResolverInterface $db
* @throws \ErrorException
*/
public function __construct(ConnectionResolverInterface $db)
{
try {
/** @var Connection $connection */
$connection = $db->connection();
$this->sql = $connection->getPdo();
$this->db = $connection->getConfig('database');
$this->pref = $connection->getConfig('prefix');
} catch (\Exception $e) {
$this->sql = false;
$this->error = $e->getMessage();
throw new \ErrorException('No Connection to Database: ' . $e->getMessage());
}
}
示例4: resolveConnection
/**
* Resolve the database connection instance.
*
* @param string $connection
* @return \Illuminate\Database\Connection
*/
public function resolveConnection($connection)
{
return $this->resolver->connection($connection);
}
示例5: resolveConnection
/**
* Resolve a connection instance by name.
*
* @param string $connection
* @return Illuminate\Database\Connection
*/
public static function resolveConnection($connection)
{
return static::$resolver->connection($connection);
}
示例6: getConnection
/**
* Resolve the database connection instance.
*
* @return \Illuminate\Database\Connection
*/
public function getConnection()
{
return $this->resolver->connection($this->connection);
}
示例7: connect
/**
* Establish a queue connection.
*
* @param array $config
* @return \Illuminate\Contracts\Queue\Queue
*/
public function connect(array $config)
{
return new DatabaseQueue($this->connections->connection(Arr::get($config, 'connection')), $config['table'], $config['queue'], Arr::get($config, 'expire', 60));
}
示例8: table
/**
* Get a query builder for the given table.
*
* @param string $table
* @return \Illuminate\Database\Query\Builder
*/
protected function table($table)
{
return $this->db->connection($this->connection)->table($table);
}
示例9: table
/**
* Get a query builder for the given table.
*
* @param string $table
* @return \Illuminate\Database\Query\Builder
*/
protected function table($table)
{
return $this->db->connection($this->connection)->table($table)->useWritePdo();
}
示例10: getConnection
/**
* Get the connection.
*
* @return \Illuminate\Database\ConnectionInterface
*/
protected function getConnection()
{
return $this->resolver->connection($this->connectionName);
}
示例11: getTable
/**
* Get a new query builder instance for the table.
*
* @return \Illuminate\Database\Query\Builder
*/
protected function getTable()
{
return $this->resolver->connection($this->database)->table($this->table);
}
示例12: microtime
function it_should_get_connection_for_source()
{
$connection = microtime();
$this->resolver->connection($this->source)->willReturn($connection);
$this->getConnection()->shouldBe($connection);
}
示例13: connect
/**
* Establish a queue connection.
*
* @param array $config
* @return \Illuminate\Contracts\Queue\Queue
*/
public function connect(array $config)
{
return new DatabaseQueue($this->connections->connection(array_get($config, 'connection')), array_get($config, 'table', 'queues'), array_get($config, 'queue', null), array_get($config, 'expire', 60), array_get($config, 'lock_type', 60));
}
示例14: errorException
/**
* @Transactional(value="testing",expect=\LogicException::class)
*
* @return string
*/
public function errorException()
{
$this->db->connection()->statement('CREATE TABLE tests (test varchar(255) NOT NULL)');
$this->db->connection()->table("tests")->insert(['test' => 'testing']);
throw new \LogicException();
}
示例15: connect
/**
* @param array $config
*
* @return CouchbaseQueue|\Illuminate\Contracts\Queue\Queue
*/
public function connect(array $config)
{
/** @var CouchbaseConnection $connection */
$connection = $this->connectionResolver->connection($config['driver']);
return new CouchbaseQueue($connection, $config['bucket'], $config['queue'], Arr::get($config, 'retry_after', 60));
}