Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
$unset in Mongo
ch00ey
November 2012
I'm trying to $unset a specific field in a mongo document and I'm not quite sure how to go about doing it in regards to using FuelPHP's Mongo class.
After a few Google searches I stumbled on how to unset with "raw" PHP:
$mongo->pianos->names->update(array(), array('$unset' => array('id' => 1)), array('multiple' => true)
(
http://www.php.net/manual/en/mongocollection.update.php
)
With that being said should I be using the update method, the command method from FuelPHP, a combination of both or would I have to go ahead and do it in "raw" PHP?
Thanks!
ch00ey
November 2012
Accepted Answer
I found an answer that works, here's the code:
$result= $mongo->where(array('_id' => idOfDocument))->update('Yourcollection', array('$unset' => array("yourField" => 1)), array(), true);
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,088
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
260
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
ch00ey
November 2012