Ejemplo n.º 1
0
 /**
  * Returns the database object (the connection)
  *
  * @return MongoDB
  */
 public static function db()
 {
     if (isset(static::$database) && static::$database instanceof MongoDB) {
         return static::$database;
     }
     if (is_null(static::$client)) {
         return Client::db(static::$database);
     }
     return static::client()->selectDB(static::$database);
 }
Ejemplo n.º 2
0
 /**
  * @depends testMakeConnection
  */
 public function testGetDB($conn)
 {
     $db = Client::db('test');
     $this->assertTrue($db instanceof MongoDB);
     $database = $conn->getDefaultDatabase();
     $this->assertEquals('test', $database);
     $conn->setDefaultDatabase('test2');
     $database = $conn->getDefaultDatabase();
     $this->assertEquals('test2', $database);
     $this->assertTrue(Model::db() instanceof MongoDB);
     $conn->setDefaultDatabase('test');
 }