示例#1
0
 public function setUp()
 {
     Configure::database(function ($config) {
         $config->default = 'db';
         $config->set(['db' => ['driver' => 'mysql', 'host' => 'localhostf', 'port' => '', 'database' => 'foo_bar', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci']]);
     });
 }
 /**
  * Setup Eloquent ORM Service Provider
  *
  * @param Application $app
  * @source https://github.com/illuminate/database
  */
 public function register(Application $app)
 {
     $this->eloquent = new EloquentCapsule();
     $config = Database::getDatabaseConfiguration();
     /**
     | We will loop over all connections
     | and set connection
     */
     foreach ($config as $key => $c) {
         $this->setConnection($c);
     }
     $this->eloquent->setEventDispatcher(new Dispatcher(new Container()));
     // Make this Capsule instance available globally via static methods... (optional)
     $this->eloquent->setAsGlobal();
     // Setup the Eloquent ORM... (optional; unless you've used setEventDispatcher())
     $this->eloquent->bootEloquent();
 }
 /**
  * @return mixed
  */
 public function getDefaultConnection()
 {
     $connection = $this->parseUrl(Configure::getDefault());
     return $connection['database'];
 }