gleez/cms — pull request #432 by sergeyklay (2013-07-10 11:05:44+00:00)
Title: Mango improvements

## Mango 0.3.0

### `Mango::execute_safe`
This method allows you to run arbitrary JavaScript on the database.
Same usage as [MongoDB::execute](http://www.php.net/manual/en/mongodb.execute.php) except it throws an exception on error.

```php
// return int, for example 789
$db->execute_safe('db.Logs.count();');

// return string 'Hello, world!'
$db->execute_safe("function() { return 'Hello, world!'; }");
```

### `Mango::command_safe`
Almost everything that is not a CRUD operation can be done with a this method.
Same usage as [MongoDB::command](http://www.php.net/manual/en/mongodb.command.php) except it throws an exception on error:

```php
$people->insert(array("name" => "Joe", "age" => 4));
$people->insert(array("name" => "Sally", "age" => 22));
$people->insert(array("name" => "Dave", "age" => 22));
$people->insert(array("name" => "Molly", "age" => 87));

$ages = $db->command_safe(array("distinct" => "people", "key" => "age"));

foreach ($ages['values'] as $age) {
echo "$age\n";
}
// 4
// 22
// 87
```