title: Where to put sql queries in Yii (or any framework with ORM support)?
body: <p>This is a more of a coding style question for projects using MVC architecture.</p>
  
  <p>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.</p>
  
  <p>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 some<code>getSomeComplexLogicData</code> method.</p>
  
  <p>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?</p>