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

Why all model fields are strings?

Why all model fields are strings? If my table column type is integer how can I get model field be the integer type?

I think do it like this is not very good:

function getId()
     return (int) $this->id;

PDO returns everything as a string, so either you hardtype everything as you yourself suggested, or you make use of something like https://www.php.net/manual/en/pdostatement.getcolumnmeta.php to determine the type manually (and cache it). It is, however, not supported by all PDO drivers.