Mongo Functions
PHP Manual

mongo_insert

(PECL mongo >= 0.8.0)

mongo_insertInserts an array into a database collection

Description

bool mongo_insert ( resource $connection , string $ns , array $query )

Inserts an array into a database collection.

Parameters

connection

The database connection to use.

ns

The database and collection name

obj

The array to insert.

Return Values

Whether the item was successfully inserted or not.

Examples

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

See Also


Mongo Functions
PHP Manual