We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Empty filed on existing date at the document on update

My question is related with mongo and Phalcon ODM, how he handle the situation when im giving an empty value to be saved on existing document with existing value? Actuly in update.

$eventsModel->date = $request->date;

$request->date can have value ,but its possible to be empty .What happens when i save this ? Is mongo read that i have value in date and decide to ignore the new null value or will overwrite the existing date with null ?

Have I make check on every field is it empty or not ?

edited Feb '15

on update:

$uid = (int) $this->request->getPost("id");

$obj = Obj::findFirst($uid);

$obj->setAttrib(
    !empty($this->request->getPost("attrib")) ? $this->request->getPost("attrib", ["validators"]) : $obj->getAttrib());

if $_POST is null or empty, takes the value already stored in the database.

I do not know if it's the best approach, but would do so.

Sorry for my english