当前位置: 首页>>代码示例>>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;未经允许,请勿转载。