title: Is there such a thing as a ViewModel equivalent in Yii? If so, how to implement one
body: <p>I am just learning Yii, and I am able to create ActiveRecord models which map to the database tables.</p>
  
  <p>Is there such a thing as a viewmodel implementation in Yii as I can't find any kind of documentation. Maybe it's called something else?</p>
  
  <p>Example:</p>
  
  <p>I have a <code>product</code> table and a <code>category</code> table of which I wish to expose the following columns in the viewmodel.</p>
  
  <pre><code>product.id
  category.name
  product.name
  product.price
  </code></pre>
  
  <p>I am aware that I can do this by referring to the fields as such individually within Yii, however the above is a cleaner / simpler version of my real much more complex database.</p>
  
  <p>As such, a ViewModel functionality whereby I can expose the columns which I want to, and then re-use it wherever I need to without repeating code would be quite handy.</p>