Mongo Funktionen
PHP Manual

mongo_insert

(PECL mongo >= 0.8.0)

mongo_insertInserts an array into a database collection

Beschreibung

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

Inserts an array into a database collection.

Parameter-Liste

connection

The database connection to use.

ns

The database and collection name

obj

The array to insert.

Rückgabewerte

Whether the item was successfully inserted or not.

Beispiele

Beispiel #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";
}

?>

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

inserted

Siehe auch


Mongo Funktionen
PHP Manual