Mongo 関数
PHP Manual

mongo_insert

(PECL mongo >= 0.8.0)

mongo_insertInserts an array into a database collection

説明

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

Inserts an array into a database collection.

パラメータ

connection

The database connection to use.

ns

The database and collection name

obj

The array to insert.

返り値

Whether the item was successfully inserted or not.

例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";
}

?>

上の例の出力は、たとえば 以下のようになります。

inserted

参考


Mongo 関数
PHP Manual