title: Yii generate a model file using php code instead of gii tool
body: <p>I'm having real problems with the following topic:</p>
  
  <p>I'm creating a social network using Yii framework and for each user I'm generating a bunch of DB tables that start with the user id, so a DB table looks like: 13_my_firends.</p>
  
  <p>The point is that by doing this, I cannot generate a certain model using the gii tool, and I really need some models for this tables to make some relations to avoid inner joins, so I guess the problem is like this:</p>
  
  <p><strong>-> How can I create a model file using php or Yii code and also, within that code alter the "public function relation(){}" method to add my relations?</strong></p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I was just thinking about this: Is there a possibility to add the relation to the parent and not the son? What I mean is... Can I alter the main DB table (witch in my case is sys_accounts - this one has a model) like: 
  -> call the relations() method in another method
  -> make the relations array (kind of like a join)</p>
  
  <p><strong>So basically it's like... altering the relations() method only when I want to. Is it possible? And if so, how?</strong></p>