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

Convert data only for saving

I've got a model with a boolean field. I've written beforeSave() to convert from boolean to 1 & 0, and afterSave() & afterFetch() to convert from 1 & 0 back to boolean.

The beforeSave() & afterSave() seem a bit silly to me - is there any way to configure my model so that the value it keeps in memory is boolean, but the value it stores is 1 & 0?

Why you don't use 0 & 1 everywhere ? In my models I don't have any bolean field to replace it I use tinyint directly.

Semantics I suppose.

Why you don't use 0 & 1 everywhere ? In my models I don't have any bolean field to replace it I use tinyint directly.