1.2.1551. ext/mongo¶
Extension MongoDB driver (legacy). Note : this is not the MongoDB driver. This is the legacy extension.
<?php
// connect
$m = new MongoClient();
// select a database
$db = $m->comedy;
// select a collection (analogous to a relational database\'s table)
$collection = $db->cartoons;
// add a record
$document = array( 'title' => 'Calvin and Hobbes', 'author' => 'Bill Watterson' );
$collection->insert($document);
// add another record, with a different 'shape'
$document = array( 'title' => 'XKCD', 'online' => true );
$collection->insert($document);
// find everything in the collection
$cursor = $collection->find();
// iterate through the results
foreach ($cursor as $document) {
echo $document['title'] . PHP_EOL;
}
?>
See also ext/mongo manual and MongdDb.
1.2.1551.1. Specs¶
Short name |
Extensions/Extmongo |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
|
Time To Fix |
|
Precision |
Very high |
Available in |