PHP code example of xtfer / vultan

1. Go to this page and download the library: Download xtfer/vultan library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xtfer / vultan example snippets



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

// Choose a database.
$vultan->useDatabase('cars');

// Choose a collection to work with.
$vultan->useCollection('marques');

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

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



$vultan = \Vultan\Vultan::connect()
  ->useDatabase('cars')
  ->useCollection('marques');

$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.
  ->resultsAsArray()
  // Run the query.
  ->execute();

print_r($result_data);