A lightweight MongoDB wrapper

0.1.2-alpha 2014-03-05 11:12 UTC


Vultan wraps the native MongoPHP driver and provides a fluent, extensible query interface.

Insert a document

// Using the connect() method without arguments returns a connection to the
// default MongoDB on localhost.
$vultan = \Vultan\Vultan::connect();

// Choose a database.

// Choose a collection to work with.

// Prepare some data.
$data = array(
  'name' => 'Rolls Royce',
  'founded' => '1906',
  'type' => 'manufacturer',
  'place' => 'Manchester'

// Insert some data.
$result = $vultan->insert($data)->execute();

Find a document

$vultan = \Vultan\Vultan::connect()

$query = $vultan->find();

$result_data = $query
  // Add some conditions.
  ->addCondition('founded', '1906')
  ->addCondition('place', 'Manchester')
  // Ensure the query returns an array. Omit this if you prefer an iterator.
  // Run the query.