(PECL mongo >= 0.8.0)
mongo_insert — Inserts an array into a database collection
Inserts an array into a database collection.
The database connection to use.
The database and collection name
The array to insert.
Whether the item was successfully inserted or not.
Example #1 mongo_insert() example
This example shows how to insert an array into a database collection.
<?php
$obj = array("x" => "y", "z" => 2.4);
$conn = mongo_connect("localhost", true);
if (!$conn) {
die("Could not connect.");
}
$ok = mongo_insert($conn, "foo.bar", $obj);
if( $ok ) {
echo "inserted";
}
?>
The above example will output something similar to:
inserted