當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Database\ConnectionResolverInterface類代碼示例

本文整理匯總了PHP中Illuminate\Database\ConnectionResolverInterface的典型用法代碼示例。如果您正苦於以下問題:PHP ConnectionResolverInterface類的具體用法?PHP ConnectionResolverInterface怎麽用?PHP ConnectionResolverInterface使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ConnectionResolverInterface類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __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());
     }
 }
開發者ID:frogsystem,項目名稱:legacy-bridge,代碼行數:19,代碼來源:Database.php

示例2: fire

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     if (!$this->confirmToProceed()) {
         return;
     }
     $this->resolver->setDefaultConnection($this->getDatabase());
     $this->getSeeder()->run();
 }
開發者ID:pin-cnx,項目名稱:orientdb-laravel-5,代碼行數:13,代碼來源:SeedCommand.php

示例3: 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.');
     }
 }
開發者ID:hochanh,項目名稱:Bootsoft-Bowling,代碼行數:13,代碼來源:SeedCommand.php

示例4: fire

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     if (!$this->confirmToProceed()) {
         return;
     }
     $this->resolver->setDefaultConnection($this->getDatabase());
     Model::unguarded(function () {
         $this->getSeeder()->__invoke();
     });
 }
開發者ID:bryanashley,項目名稱:framework,代碼行數:15,代碼來源:SeedCommand.php

示例5: handle

 /**
  * @return mixed
  */
 public function handle()
 {
     // TODO: Implement handle() method.
     if (!$this->confirmToProceed()) {
         return;
     }
     $this->resolver->setDefaultConnection($this->getDatabase());
     Model::unguarded(function () {
         $this->getSeeder()->run();
     });
 }
開發者ID:filipveschool,項目名稱:packagegenerator,代碼行數:14,代碼來源:MakeSeederCommand.php

示例6: 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;
 }
開發者ID:spira,項目名稱:api-core,代碼行數:18,代碼來源:TransactionMiddleware.php

示例7: fire

 /**
  * 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();
     }
 }
開發者ID:stillat,項目名稱:database,代碼行數:18,代碼來源:SeedCommand.php

示例8: setConnection

 /**
  * 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;
 }
開發者ID:EnmanuelCode,項目名稱:backend-laravel,代碼行數:14,代碼來源:Migrator.php

示例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);
 }
開發者ID:rosskmurphy,項目名稱:Laravel-4-login-registration,代碼行數:10,代碼來源:DatabasePresenceVerifier.php

示例10: 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();
 }
開發者ID:bryanashley,項目名稱:framework,代碼行數:10,代碼來源:DatabasePresenceVerifier.php

示例11: getConnection

 /**
  * Get the connection.
  *
  * @return \Illuminate\Database\ConnectionInterface
  */
 protected function getConnection()
 {
     return $this->resolver->connection($this->connectionName);
 }
開發者ID:appotter,項目名稱:oauth2-server-msp,代碼行數:9,代碼來源:AbstractFluentAdapter.php

示例12: resolveConnection

 /**
  * Resolve a connection instance by name.
  *
  * @param  string  $connection
  * @return Illuminate\Database\Connection
  */
 public static function resolveConnection($connection)
 {
     return static::$resolver->connection($connection);
 }
開發者ID:hochanh,項目名稱:Bootsoft-Bowling,代碼行數:10,代碼來源:Model.php

示例13: microtime

 function it_should_get_connection_for_source()
 {
     $connection = microtime();
     $this->resolver->connection($this->source)->willReturn($connection);
     $this->getConnection()->shouldBe($connection);
 }
開發者ID:mtahv3,項目名稱:SmartSeeder,代碼行數:6,代碼來源:SmartSeederRepositorySpec.php

示例14: 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));
 }
開發者ID:brucewu16899,項目名稱:laravel-database-queue,代碼行數:10,代碼來源:DatabaseConnector.php

示例15: 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();
 }
開發者ID:ytake,項目名稱:laravel-aspect,代碼行數:11,代碼來源:AspectTransactionalDatabase.php


注:本文中的Illuminate\Database\ConnectionResolverInterface類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。