作者:frogsyste
项目:legacy-bridg
/**
* 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());
}
}
作者:pin-cn
项目:orientdb-laravel-
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
if (!$this->confirmToProceed()) {
return;
}
$this->resolver->setDefaultConnection($this->getDatabase());
$this->getSeeder()->run();
}
作者:hochan
项目:Bootsoft-Bowlin
/**
* 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.');
}
}
作者:bryanashle
项目:framewor
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
if (!$this->confirmToProceed()) {
return;
}
$this->resolver->setDefaultConnection($this->getDatabase());
Model::unguarded(function () {
$this->getSeeder()->__invoke();
});
}
作者:filipveschoo
项目:packagegenerato
/**
* @return mixed
*/
public function handle()
{
// TODO: Implement handle() method.
if (!$this->confirmToProceed()) {
return;
}
$this->resolver->setDefaultConnection($this->getDatabase());
Model::unguarded(function () {
$this->getSeeder()->run();
});
}
作者:spir
项目:api-cor
/**
* @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;
}
作者:stilla
项目:databas
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
$tenants = $this->manager->getRepository()->getTenants();
$seeder = $this->getSeeder();
foreach ($tenants as $tenant) {
$this->manager->bootstrapConnectionByTenantName($tenant->tenant_name);
$this->resolver->setDefaultConnection($tenant->tenant_name);
$this->manager->assumeTenant($tenant->id, true);
$seeder->run();
$this->output->writeln('<info>Seeded tenant ' . $tenant->tenant_name . '</info>');
$this->manager->restoreTenant();
}
}
作者:EnmanuelCod
项目:backend-larave
/**
* Set the default connection name.
*
* @param string $name
* @return void
*/
public function setConnection($name)
{
if (!is_null($name)) {
$this->resolver->setDefaultConnection($name);
}
$this->repository->setSource($name);
$this->connection = $name;
}
作者:rosskmurph
项目:Laravel-4-login-registratio
/**
* 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);
}
作者:bryanashle
项目:framewor
/**
* 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();
}
作者:appotte
项目:oauth2-server-ms
/**
* Get the connection.
*
* @return \Illuminate\Database\ConnectionInterface
*/
protected function getConnection()
{
return $this->resolver->connection($this->connectionName);
}
作者:hochan
项目:Bootsoft-Bowlin
/**
* Resolve a connection instance by name.
*
* @param string $connection
* @return Illuminate\Database\Connection
*/
public static function resolveConnection($connection)
{
return static::$resolver->connection($connection);
}
作者:mtahv
项目:SmartSeede
function it_should_get_connection_for_source()
{
$connection = microtime();
$this->resolver->connection($this->source)->willReturn($connection);
$this->getConnection()->shouldBe($connection);
}
作者:brucewu1689
项目:laravel-database-queu
/**
* 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));
}
作者:ytak
项目:laravel-aspec
/**
* @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();
}
作者:EnmanuelCod
项目:backend-larave
/**
* 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));
}
作者:asifalim
项目:cor
/**
* Resolve the database connection instance.
*
* @return \Illuminate\Database\Connection
*/
public function getConnection()
{
return $this->resolver->connection($this->connection);
}
作者:ngitimfoy
项目:Nyari-AppPH
/**
* 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);
}
作者:flelievr
项目:EasyVisi
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
$this->resolver->setDefaultConnection($this->getDatabase());
$this->getSeeder()->run();
}
作者:ytak
项目:laravel-couchbas
/**
* @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));
}