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

Saving a model after finding with selected fields

I'm retrieving some models but only need to work with a single property. I use find() restricting properties with the fields query option.

I need to save and have ONLY this property changed. When I save(), the other properties get destroyed.

How can I do this properly?



5.1k
edited Jul '17

hello

you can implement beforeupdate function in you model and clear other property



8.7k

I don't want to clear the other properties; I want them to be unchanged. I only want to update a single property, the property I specify with the fields in the query.

hello

you can implement beforeupdate function in you model and clear other property



5.1k

look at Dynamic update to do this



8.7k

Does with work with the ODM?



5.1k
edited Jul '17

Sorry i have forgot it's for ODM not ORM

Dynamic update is in Phalcon\Mvc\Model; not in Phalcon\Mvc\Collection;