当前位置: 首页>>代码示例>>PHP>>正文


PHP DB::getFacadeRoot方法代码示例

本文整理汇总了PHP中Illuminate\Support\Facades\DB::getFacadeRoot方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::getFacadeRoot方法的具体用法?PHP DB::getFacadeRoot怎么用?PHP DB::getFacadeRoot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Support\Facades\DB的用法示例。


在下文中一共展示了DB::getFacadeRoot方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getDefaultDb

 /**
  * Get a default db value, if any is available
  *
  * @return ConnectionInterface|null A default db value or Null if no default value is available
  */
 public function getDefaultDb()
 {
     // By default, the DB Facade does not return the
     // any actual database connection, but rather an
     // instance of \Illuminate\Database\DatabaseManager.
     // Therefore, we make sure only to obtain its
     // "connection", to make sure that its only the connection
     // instance that we obtain.
     $manager = DB::getFacadeRoot();
     if (!is_null($manager)) {
         return $manager->connection();
     }
     return $manager;
 }
开发者ID:aedart,项目名称:laravel-helpers,代码行数:19,代码来源:DBTrait.php

示例2: attempt

 /**
  * Attempt a DB operation - utilising a transaction
  *
  * @param  callable  $callback
  *
  * @return mixed
  */
 public function attempt(callable $callback)
 {
     DB::beginTransaction();
     try {
         $value = $callback(DB::getFacadeRoot());
         DB::commit();
     } catch (\Exception $e) {
         DB::rollBack();
         throw $e;
     }
     return $value;
 }
开发者ID:tamnil,项目名称:laravel-repositories,代码行数:19,代码来源:Repository.php

示例3: setUp

 /**
  * Setup before each test.
  */
 public function setUp()
 {
     parent::setUp();
     $this->options = new OptionsService(DB::getFacadeRoot(), 'options');
 }
开发者ID:rawphp,项目名称:laravel-options,代码行数:8,代码来源:OptionsServiceTest.php

示例4: getDefaultDbManager

 /**
  * Get a default db manager value, if any is available
  *
  * @return DatabaseManager|null A default db manager value or Null if no default value is available
  */
 public function getDefaultDbManager()
 {
     return DB::getFacadeRoot();
 }
开发者ID:aedart,项目名称:laravel-helpers,代码行数:9,代码来源:DBManagerTrait.php

示例5: connection

 /**
  * Get a database schema builder instance for the
  * given connection.
  *
  * @param string $name
  *
  * @return \Illuminate\Database\Schema\Builder|null Returns null when no database connection is available
  */
 public function connection($name)
 {
     // We do this check to ensure that a connection is available
     $manager = DB::getFacadeRoot();
     if (!is_null($manager) && !is_null($manager->connection())) {
         return Schema::connection($name);
     }
     return $manager;
 }
开发者ID:aedart,项目名称:laravel-helpers,代码行数:17,代码来源:SchemaTrait.php


注:本文中的Illuminate\Support\Facades\DB::getFacadeRoot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。