Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
$unset in Mongo
  • 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)


    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!

  • ch00eych00ey
    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);

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion