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

Is it necessary to create a Model?

Hello.

Is it necessary to create a "Model" class for each table in the database?

No, you can create only the classes that you want to actually use. Or not create any model classes at all, and use raw SQL ($this->db->query / execute / fetch / fetchAll)

No it's not. You can use raw queries. But if you want to use Resultset classes or PHQL you need model classes.



9.7k

Models, ORM, and all that stuff can save you development time but sometimes the generated SQL is slow. You can use PDO for speed. Models appear to assume updates which means there could be less overhead for read only access through PDO and SQL. When you have no models, you can load services manually and load a smaller PDO service. I use that approach for some read only pages.