This is a more of a coding style question for projects using MVC architecture.
I'm working on a project using Yii framework. Each database table has it's own model class and lets me take advantage of Yii's Active Record stuff. Cool.
But now I need to do an SQL query with a complex logic and a lot of tables being joined.
The best and quickest way to do this is to write a raw SQL and put it in somegetSomeComplexLogicData
method.
The question is, where do I put this method? Is it a good practice to leave it in a controller where I'm calling it (it's highly unlikely that it will be re-used anywhere else), or should I put it in some Model class that it best corresponds with?