I’m learning Symfony + Doctrine 1.2 by writing a web app. As the app grows in size, I would like to know where I should place my functions that wrap commonly used queries. Is it good practice to create a custom library class and place all the functions there? Currently, I have been placing the functions inside the Table class that Doctrine generates.
For example:
- getAllMessagesByUserId($userId) is a function in the MessageTable class.
- getOnlineUsers() is a function in the UserTable class.
Personally, I would prefer to have all the queries in one place, but I’m concerned that I would be breaking a “best-practice” rule.
What are your thoughts?
They should be exactly where you have them… on the table classes for the models they query.