We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Model data type casting

Hello everyone ! I spend some time looking for well solution to automaticlly cast data fetched from database and I didn't find out any elegant solution so I creat this thread. My question is: How I can implement type casting for model to ensure it always will be casted and to make this improvmed transparent? I don't want to rewrite whole application to use $model->getAge() instead of already using $model->age. I know PDO don't cast data itself (sic!) and comments in model classes are not ORM annotations.



2.8k
Accepted
answer