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


PHP Manager::setAsGlobal方法代碼示例

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


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

示例1: init

 public function init()
 {
     $this->capsule = new Capsule();
     $this->capsule->addConnection(['driver' => 'mysql', 'host' => DB_HOST, 'port' => DB_PORT, 'database' => DB_NAME, 'username' => DB_USER, 'password' => DB_PASSWORD, 'charset' => DB_CHARSET, 'collation' => DB_COLLATION]);
     $this->capsule->bootEloquent();
     $this->capsule->setAsGlobal();
 }
開發者ID:joppuyo,項目名稱:Dullahan,代碼行數:7,代碼來源:Migration.php

示例2: __construct

 private function __construct()
 {
     $this->capsule = new Capsule();
     $this->capsule->addConnection(['driver' => 'mysql', 'host' => DB_HOST, 'database' => DB_NAME, 'username' => DB_USER, 'password' => DB_PASSWORD, 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '']);
     $this->capsule->setEventDispatcher(new Dispatcher(new Container()));
     $this->capsule->setAsGlobal();
 }
開發者ID:hieu-pv,項目名稱:NFWP,代碼行數:7,代碼來源:DBManager.php

示例3: _makeEloquent

 /**
  * Setup eloquent database
  * @param \Illuminate\Database\Capsule\Manager $capsule
  * @throws \Lassi\App\Exception\NotFoundException
  * @return \Lassi\App\Database
  */
 private function _makeEloquent(Capsule $capsule)
 {
     // Throw exception if minimum requirements not met
     if (!getenv('db_driver') || !getenv('db_name')) {
         throw new NotFoundException('App configurations not found.');
     }
     // Get capsule instance
     $this->capsule = $capsule;
     // Cache db driver
     $db_driver = getenv('db_driver');
     // Setup connection defaults
     $configs = array('driver' => $db_driver, 'database' => getenv('db_name'), 'prefix' => getenv('db_prefix'), 'charset' => getenv('db_charset'), 'collation' => getenv('db_collation'));
     // Add extras depending on type of driver/connection
     if ($db_driver !== 'sqlite') {
         if (getenv('db_host')) {
             $configs['host'] = getenv('db_host');
         }
         if (getenv('db_username')) {
             $configs['username'] = getenv('db_username');
         }
         if (getenv('db_password')) {
             $configs['password'] = getenv('db_password');
         }
     }
     // Setup connection
     $this->capsule->addConnection($configs);
     // Set as global
     $this->capsule->setAsGlobal();
     // Boot eloquent
     $this->capsule->bootEloquent();
     return $this;
 }
開發者ID:leandrocanabarro,項目名稱:lassi,代碼行數:38,代碼來源:Database.php

示例4: initialize

 /**
  * Initializes the connection manager and its dependencies.
  */
 protected function initialize()
 {
     $this->capsule = new Capsule();
     $this->capsule->setEventDispatcher(new Dispatcher(new Container()));
     $this->capsule->setAsGlobal();
     $this->capsule->bootEloquent();
 }
開發者ID:larrytech,項目名稱:calendar,代碼行數:10,代碼來源:Connector.php

示例5: setConnection

 protected function setConnection(array $connection)
 {
     $this->capsule = new Capsule();
     $this->capsule->addConnection($connection);
     $this->capsule->setAsGlobal();
     $this->capsule->bootEloquent();
 }
開發者ID:xandros15,項目名稱:aigisu,代碼行數:7,代碼來源:Connection.php

示例6: bootstrap

 /**
  * {@inheritdoc}
  */
 public function bootstrap($app)
 {
     $this->capsule = new Manager();
     $this->capsule->addConnection(['driver' => $this->driver, 'host' => $this->host, 'database' => $this->database, 'username' => $this->username, 'password' => $this->password, 'charset' => $this->charset, 'collation' => $this->collation, 'prefix' => $this->prefix]);
     $this->capsule->setEventDispatcher(new Dispatcher(new Container()));
     $this->capsule->setAsGlobal();
     $this->capsule->bootEloquent();
     $app->set('db', $this->capsule);
 }
開發者ID:lordthorzonus,項目名稱:yii2-eloquent,代碼行數:12,代碼來源:Yii2Eloquent.php

示例7: setUpBeforeClass

 /**
  * set up eloquent for test
  */
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     self::$manager = new Manager();
     // TODO: add dotenv and extract for reuse
     self::$manager->addConnection(['driver' => 'mysql', 'host' => 'localhost', 'database' => 'grimm', 'username' => 'homestead', 'password' => 'secret', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'engine' => null]);
     self::$manager->setAsGlobal();
     self::$manager->bootEloquent();
 }
開發者ID:grimmdevelop,項目名稱:models,代碼行數:12,代碼來源:PersonsTest.php

示例8: getCapsule

 /**
  * @return \Illuminate\Database\Capsule\Manager
  */
 public function getCapsule()
 {
     if (!$this->capsule) {
         $this->capsule = new Capsule();
         $this->capsule->addConnection($this->configuration);
         $this->capsule->setAsGlobal();
     }
     return $this->capsule;
 }
開發者ID:tomzx,項目名稱:irc-stats,代碼行數:12,代碼來源:DatabaseProxy.php

示例9: createConnection

 protected function createConnection()
 {
     $this->capsule = new Capsule();
     $this->capsule->addConnection(['driver' => 'sqlite', 'database' => __DIR__ . '/db/testing.sqlite', 'prefix' => '']);
     $this->capsule->setFetchMode(PDO::FETCH_CLASS);
     $this->capsule->setAsGlobal();
     $this->capsule->bootEloquent();
     $this->capsule->getConnection()->enableQueryLog();
 }
開發者ID:leloulight,項目名稱:trigglog,代碼行數:9,代碼來源:TestCase.php

示例10: addDbConnection

 /**
  * @param array $credentials
  */
 public function addDbConnection($credentials = [])
 {
     if (empty($credentials)) {
         $bitrixDbCredentials = \Bitrix\Main\Application::getInstance()->getConnection()->getConfiguration();
         $credentials = ['driver' => 'mysql', 'database' => $bitrixDbCredentials['database'], 'username' => $bitrixDbCredentials['login'], 'password' => $bitrixDbCredentials['password'], 'host' => $bitrixDbCredentials['host'], 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false];
     }
     $this->capsule->addConnection($credentials);
     $this->capsule->setAsGlobal();
     $this->capsule->bootEloquent();
 }
開發者ID:osotov,項目名稱:illuminate-for-bitrix,代碼行數:13,代碼來源:Bootstrapper.php

示例11: __construct

 /**
  * Database constructor.
  */
 public function __construct()
 {
     $this->capsule = new Manager();
     /**
      * Add a connection
      */
     $this->capsule->addConnection($this->GetDatabaseSettings());
     /**
      * Globalise it
      */
     $this->capsule->setAsGlobal();
 }
開發者ID:CrashfortStudios,項目名稱:Savant,代碼行數:15,代碼來源:Database.php

示例12: instance

 /**
  * @return \Illuminate\Database\Capsule\Manager
  */
 public static function instance()
 {
     if (static::$_instance === null) {
         $config = Config::get("database");
         static::$_instance = new \Illuminate\Database\Capsule\Manager();
         if ($config["connections"] && is_array($config["connections"])) {
             foreach ($config["connections"] as $key => $cfg) {
                 static::$_instance->addConnection($cfg, $key);
             }
         }
         static::$_instance->setAsGlobal();
     }
     return static::$_instance;
 }
開發者ID:ohworkit,項目名稱:Sirius,代碼行數:17,代碼來源:DB.php

示例13: CreateConnection

 /**
  * Create the connection
  *
  * @return bool
  */
 public function CreateConnection()
 {
     $information = $this->GetInformation();
     if ($information == null) {
         return false;
     }
     try {
         $this->database->addConnection($information);
         $this->database->setAsGlobal();
     } catch (\Exception $error) {
         return false;
     }
     return true;
 }
開發者ID:crashfortstudios,項目名稱:framework,代碼行數:19,代碼來源:Database.php

示例14: AddConnection

 /**
  * Adds a connection
  */
 public function AddConnection()
 {
     /**
      * Lets get our database settings
      */
     $settings = Settings::GetDatabaseSettings();
     /**
      * Then lets start a connection
      */
     $this->capsule->addConnection($settings);
     /**
      * Then lets globalise this connection
      */
     $this->capsule->setAsGlobal();
 }
開發者ID:CrashfortStudios,項目名稱:Sirus,代碼行數:18,代碼來源:Database.php

示例15: initCapsule

 /**
  * Init capsule
  */
 public function initCapsule()
 {
     $this->capsule = new Capsule();
     switch ($this->configDatabase['driver']) {
         case 'mysql':
             $configConnection = ['driver' => 'mysql', 'host' => $this->configDatabase['host'], 'database' => $this->configDatabase['database'], 'username' => $this->configDatabase['username'], 'password' => $this->configDatabase['password'], 'charset' => $this->configDatabase['charset'], 'collation' => $this->configDatabase['collation']];
             if (isset($this->configDatabase['prefix'])) {
                 $configConnection['prefix'] = $this->configDatabase['prefix'];
             }
             $this->capsule->addConnection($configConnection);
             break;
     }
     $this->capsule->setAsGlobal();
     $this->capsule->bootEloquent();
 }
開發者ID:Janoski,項目名稱:futurtravel,代碼行數:18,代碼來源:Database.php


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