Database Reference
In-Depth Information
ensure that the majority of replica nodes will acknowledge the save, or to a specific tag,
ensuring that those nodes tagged will acknowledge the save. This option defaults to 1,
acknowledging the save operation.
j : If set to true, this Boolean option will force the data to be written to the journal before
indicating the save was a success. Defaults to false.
wtimeout : Used to specify how long the server is to wait for receiving acknowledgement
(in milliseconds). Defaults to 10000.
timeout : Used to specify how long (in milliseconds) the client needs to wait for a response
from the database.
The syntax for PHP's save() version is similar to that in the MongoDB shell, as the following example illustrates:
// Specify the document to be saved
$contact = array(
"Given Name" => "Kenji",
"Family Name" => "Kitahara",
"Address" => array(
"Street" => "149 Bartlett Avenue",
"Place" => "Southfield",
"Postal Code" => "MI 48075",
"Country" => "USA"
)
,
"E-Mail" => array(
" kk@example.com " ,
" kk@office.com "
),
"Phone" => "248-510-1562",
"Age" => 34
);
// Connect to the database
$c = new MongoClient();
// Select the collection 'people'
$collection = $c->contacts->people;
// Save via the save() function
$options = array("fsync" => true);
// Specify the save() options
$collection->save($contact,$options);
// Realizing you forgot something, let's upsert this contact:
$contact['Category'] = 'Work';
// Perform the upsert
$collection->save($contact);
 
Search WWH ::




Custom Search