lithium\data\source\MongoDb::sources PHP Method

sources() public method

Returns the list of collections in the currently-connected database.
public sources ( string $class = null ) : array
$class string The fully-name-spaced class name of the model object making the request.
return array Returns an array of objects to which models can connect.
    public function sources($class = null)
    {
        $this->_checkConnection();
        $conn = $this->connection;
        return array_map(function ($col) {
            return $col->getName();
        }, $conn->listCollections());
    }

Usage Example

Ejemplo n.º 1
0
 public function testSourcesNoConnectionException()
 {
     $db = new MongoDb(array('host' => null, 'autoConnect' => false));
     $this->assertException('Could not connect to the database.', function () use($db) {
         $db->sources(null);
     });
 }
All Usage Examples Of lithium\data\source\MongoDb::sources