note 100719 added to mongocollection.update
| From: | rithish | Date: | Tue, 02 Nov 2010 13:22:37 +0000 |
| Subject: | note 100719 added to mongocollection.update | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-173683@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().
[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.
----
Server IP: 69.147.83.197
Probable Submitter: 119.226.211.163
----
Manual Page -- http://www.php.net/manual/en/mongocollection.update.php
Edit -- https://master.php.net/note/edit/100719
Del: integrated -- https://master.php.net/note/delete/100719/integrated
Del: useless -- https://master.php.net/note/delete/100719/useless
Del: bad code -- https://master.php.net/note/delete/100719/bad+code
Del: spam -- https://master.php.net/note/delete/100719/spam
Del: non-english -- https://master.php.net/note/delete/100719/non-english
Del: in docs -- https://master.php.net/note/delete/100719/in+docs
Del: other reasons-- https://master.php.net/note/delete/100719
Reject -- https://master.php.net/note/reject/100719
Search -- https://master.php.net/manage/user-notes.php