Mongo Funkcje
PHP Manual

mongo_update

(PECL mongo >= 0.8.0)

mongo_updateUpdates objects in a database collection

Opis

bool mongo_update ( resource $connection , string $ns , array $query , array $newobj , bool $upsert )

Removes matching objects, changes them to match a new object form, and resaves them to the database. If there are no matching objects and upsert is set, the new object will be inserted into the database.

Parametry

connection

The database connection to use.

ns

The database and collection name

query

The object for which to query.

newobj

The object to replace matches with.

upsert

Whether to insert newobj into the collection if no objects are returned by the query.

Zwracane wartości

If the update was successful.

Błędy/Wyjątki

When does this function issue E_* level errors, and/or throw exceptions.

Przykłady

Przykład #1 mongo_update() example

This example shows how to update an existing object.

<?php

$query 
= array("x" => "y");
$newobj = array("x" => "z");

$conn mongo_connect("localhost"true);
if (!
$conn) {
   die(
"Could not connect.");
}
$ok mongo_update($conn"foo.bar"$query$newobjfalse);
if( 
$ok ) {
  echo 
"updated";
}


?>

Powyższy przykład wyświetli coś podobnego do:

updated

Zobacz też:


Mongo Funkcje
PHP Manual