Example #1
0
 /**
  * Get the database connection
  * 
  * @return Client
  */
 protected static function getDB()
 {
     $db = \Jasny\DB::conn();
     if (!$db instanceof Client) {
         throw new Exception("Default connection isn't a REST client");
     }
     return $db;
 }
Example #2
0
 /**
  * Get the database connection
  * 
  * @return \Jasny\DB
  */
 protected static function getDB()
 {
     $name = static::meta()['db'] ?: 'default';
     $db = \Jasny\DB::conn($name);
     if (!$db instanceof Jasny\DB\REST\Client) {
         throw new Exception("Selected database connection {$name} is not a REST client");
     }
     return $db;
 }
Example #3
0
 /**
  * Get the database connection
  * 
  * @return \Jasny\DB
  */
 protected static function getDB()
 {
     $name = static::meta()['db'] ?: 'default';
     return \Jasny\DB::conn($name);
 }
Example #4
0
 /**
  * Get the name of the connection.
  * If the connection has multiple names, returns the first one.
  * 
  * @return string|null
  */
 public function getConnectionName()
 {
     return DB::getRegisteredName($this);
 }
Example #5
0
 /**
  * Test DB::getConnectionClass() with a single loaded driver
  * 
  * @expectedException \Exception
  * @expectedExceptionMessage Please specify the database driver. The following are supported: dummy, foo
  */
 public function testGetConnectionClass_Err()
 {
     $fn = new \ReflectionMethod('Jasny\\DB', 'getConnectionClass');
     $fn->setAccessible(true);
     DB::$drivers = ['nonexistent' => 'Jasny\\DB\\NonExistent', 'dummy' => self::$dummyClass];
     self::addMockDriver('foo');
     $fn->invoke(null);
 }
Example #6
0
 /**
  * Get the database connection
  * 
  * @return \Jasny\DB
  */
 protected static function getDB()
 {
     return \Jasny\DB::conn();
 }