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

Collection Model with get-set

Today I've encountered an issue with a project I'm working on, I've created a model for Mongo with protected variables and get-set functions however, upon calling the save() function no protected variables are saved even though they have been set with their respective setter. In order for the model to work it seems I have to make all variables public without setters.

Is this a bug or intentional?



98.9k
Accepted
answer

Phalcon ODM does not check for setters/getters to change model values, Phalcon uses writeAttribute/readAttribute to change values no matter of their visibility.