downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

MongoCollection::__toString> <MongoCollection::remove
Last updated: Fri, 20 Nov 2009

view this page in

MongoCollection::save

(PECL mongo >=0.9.0)

MongoCollection::saveSaves an object to this collection

Description

public boolean MongoCollection::save ( array $a )

If the object is from the database, update the existing database object, otherwise insert this object.

Parameters

a

Array to save.

Return Values

Returns if the object was saved.

Examples

Example #1 MongoCollection::save() example

<?php

$obj 
= array('x' => 1);

// insert $obj into the db
$collection->save($obj);

// add another field
$obj['foo'] = 'bar';

// $obj cannot be inserted again, causes duplicate _id error
$collection->insert($obj);

// save updates $obj with the new field
$collection->save($obj);

?>


add a note add a note User Contributed Notes
MongoCollection::save
There are no user contributed notes for this page.

MongoCollection::__toString> <MongoCollection::remove
Last updated: Fri, 20 Nov 2009
 
 
show source | credits | sitemap | contact | advertising | mirror sites