當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。