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


PHP DB::disconnect方法代碼示例

本文整理匯總了PHP中Illuminate\Support\Facades\DB::disconnect方法的典型用法代碼示例。如果您正苦於以下問題:PHP DB::disconnect方法的具體用法?PHP DB::disconnect怎麽用?PHP DB::disconnect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Support\Facades\DB的用法示例。


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

示例1: tearDown

 public function tearDown()
 {
     $this->beforeApplicationDestroyed(function () {
         DB::disconnect();
     });
     parent::tearDown();
 }
開發者ID:ihatehandles,項目名稱:AbuseIO,代碼行數:7,代碼來源:TestCase.php

示例2: handle

 /**
  * Sets the connection's database to the current user database
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // Get the current authenticated user
     $user = Auth::user();
     // Close any connection made before to avoid conflicts
     DB::disconnect('tenantdb');
     // Set the connection's database to the user's own database
     Config::set('database.connections.tenantdb.database', storage_path() . '/' . $user->database);
     return $next($request);
 }
開發者ID:bran921007,項目名稱:laravel-multi-db,代碼行數:17,代碼來源:SetUserDatabase.php

示例3: create

 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 public function create(array $data)
 {
     $user = User::create(['name' => $data['name'], 'email' => $data['email'], 'database' => $data['name'] . '.sqlite', 'password' => bcrypt($data['password'])]);
     // Create the new user sqlite database
     Storage::put($user->database, '');
     // Close any connection made with tenantdb
     DB::disconnect('tenantdb');
     // Set the tenant connection to the users own database
     Config::set('database.connections.tenantdb.database', storage_path() . '/' . $user->database);
     // Run migrations for the new db
     Artisan::call('migrate', ['--database' => 'tenantdb', '--path' => 'database/migrations/tenant']);
     return $user;
 }
開發者ID:bran921007,項目名稱:laravel-multi-db,代碼行數:19,代碼來源:Registrar.php

示例4: getObras

 /**
  * Obtiene las obras de un usuario cadeco de todas las bases de datos definidas
  *
  * @param $idUsuario
  * @return Collection|Obra
  */
 public function getObras($idUsuario)
 {
     $obrasUsuario = new Collection();
     $basesDatos = BaseDatosCadeco::where('activa', true)->orderBy('nombre')->get();
     foreach ($basesDatos as $bd) {
         $this->config->set('database.connections.cadeco.database', $bd->nombre);
         $usuarioCadeco = $this->getUsuarioCadeco($idUsuario);
         $obras = $this->getObrasUsuario($usuarioCadeco);
         foreach ($obras as $obra) {
             $obra->databaseName = $bd->nombre;
             $obrasUsuario->push($obra);
         }
         DB::disconnect('cadeco');
     }
     $perPage = 10;
     $currentPage = Paginator::resolveCurrentPage();
     $currentPage = $currentPage ? $currentPage : 1;
     $offset = $currentPage * $perPage - $perPage;
     $paginator = new LengthAwarePaginator($obrasUsuario->slice($offset, $perPage), $obrasUsuario->count(), $perPage);
     return $paginator;
 }
開發者ID:Grupo-Hermes-Infraestructura,項目名稱:core,代碼行數:27,代碼來源:EloquentUserRepository.php

示例5: disconnect

 public function disconnect($site_id)
 {
     DB::disconnect($site_id . '_production');
 }
開發者ID:enotsokolov,項目名稱:vp_plus,代碼行數:4,代碼來源:External.php


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