title: Yii: Add a condition to every query
body: <p>I want to add a certain condition to every single query that is executed. So a certain column within a table needs to be a certain value. I would use defaultScope, but it applies only to SELECT queries. This certain column of course exist in every table throughout the whole database. </p>
  
  <p>EDIT:</p>
  
  <p>The following table:</p>
  
  <pre><code>  CREATE TABLE `table` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `name` varchar(200) NOT NULL,
    `assigned_user`  int(11) NOT NULL,
    PRIMARY KEY (`id`)
    );
  </code></pre>
  
  <p>A certain user having ID 1 shall be able to see, edit etc. records that have the value 1 in <code>assigned_user</code>. Using defaultScope he cant see anything else than those, however he is still able to use other query types of the model on records that do not have assigned_user set to 1. This is exactly what I want to restrict, so there is no way he can access other records, by any URL change or different POST variable. </p>
  
  <p>Thanks for every hint, answer and suggestion :)</p>