/**
  * Register the service provider
  *
  * @return void
  */
 public function register()
 {
     $this->app->resolving('db', function ($db) {
         $db->extend('crate', function ($config) {
             $connector = new Connector();
             $connection = $connector->connect($config);
             $database = $config['database'] ?: 'doc';
             return new Connection($connection, $database);
         });
     });
 }
 /**
  * Register the service provider
  *
  * @return void
  */
 public function register()
 {
     $this->app->resolving('db', function ($db) {
         $db->extend('crate', function ($config, $name) {
             $config['name'] = $name;
             $connector = new Connector();
             $connection = $connector->connect($config);
             $database = $config['database'] ?: 'doc';
             $prefix = isset($config['prefix']) ? $config['prefix'] : '';
             return new Connection($connection, $database, $prefix, $config);
         });
     });
 }
Пример #3
0
 private function setConnection()
 {
     $connector = new Connector();
     $connection = $connector->connect(['host' => 'localhost', '20000']);
     return new Connection($connection, 'doc');
 }
Пример #4
0
 /** @test */
 function it_creates_pdo_connection_for_multiple_hosts()
 {
     $connector = new Connector();
     $connection = $connector->connect(['host' => '127.0.0.1,10.0.0.1', 'port' => 4200]);
     $this->assertInstanceOf('Crate\\PDO\\PDO', $connection);
 }