There are two types of updates you can use: modifying updates and replacing
   updates.  Modifying updates contain $-operators and change fields in a 
   document: they might increment counters, push new elements onto an array, 
   or change the type of a field.
  
  
<?php
/** suppose documents look like:
 * {"username" : "...", "password" : "...", "email" : "..."}
 */
$coll->update(array("username" => "joe"), array('$set' => array("twitter" => "@joe4153")));
/** now the document will look like:
 * {"username" : "joe", "password" : "...", "email" : "...", "twitter" : "@joe4153"}
 */
?>
    
  
  
   Replacing updates replace the entire matching document with a new document.
   They are generally not as efficient as using $-modifiers, but can be very
   usefully for complex operations or updates that can't be expressed in terms
   of $-operators.
  
  
   For example, a replacing update can completely change the structure of a
   document.
   
<?php
/** suppose documents look like:
 * {"username" : "...", "password" : "...", "email" : "..."}
 */
$coll->update(array("username" => "joe"), array("userId" => 12345, "info" => array(
    "name" => "joe", "twitter" => "@joe4153", "email" => "..."), "likes" => array()));
/** now the document will look like:
 * {
 *     "userId" : 12345, 
 *     "info" : {
 *         "name" : "joe", 
 *         "twitter" : "@joe4153", 
 *         "email" : "..."
 *     },
 *     "likes" : []
 * }
 */
?>