note 100719 modified in mongocollection.update by danbrown

From: Date: Tue, 02 Nov 2010 14:21:58 +0000
Subject: note 100719 modified in mongocollection.update by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-173684@lists.php.net to get a copy of this message
Do note, for incrementing a value using $inc, typecast the value to an integer before passing the new object to update(). <?php $votes = (int) $votes; $newData = array('$inc' => array('votes'=>$votes)); $c->update(array("firstname" => "Bob"), $newData); ?> This is especially noteworthy, if you are taking values from $_GET and pushing them for increment. --was-- Do note, for incrementing a value using $inc, typecast the value to an integer before passing the new object to update(). [code] $votes = (int) $votes; $newData = array('$inc' => array('votes'=>$votes)); $c->update(array("firstname" => "Bob"), $newData); [/code] This is especially noteworthy, if you are taking values from $_GET and pushing them for increment. http://php.net/manual/en/mongocollection.update.php

« previous php.notes (#173684) next »