ODM setting/unsetting fields

Here is the non-working code:

class User extends \Phalcon\Mvc\Collection
{
    public $login;
    public $email;
    public $password;

    public $confirmed = false;
    public $confirmationCode;

    public function confirm()
    {
        $this->confirmed = true; // can be eliminated
        unset($this->confirmationCode);
        $this->save();
    }
}

Basic account entity, supposed to be confirmed via email. PHP unsetting as well as initializing fields some fields which weren't initialized(persisted) at first save and resaving doesn't work. Natively $set and $unset operators used in update. ODM equivalent for update is save. What is the workaround?

edited Mar '14

Nvm - Answer not relevant.



5.1k
$this->getDI()->getShared('mongo')->
            selectCollection('user')->
            update(array('_id' => $this->_id), array('$unset' => array('confirmationCode' => '')));