How to built in often used sql conditions in models?

I am building a multisite app where all queries are based on the siteId and must have a WHERE siteId = ‘’ clause.

Currently I am setting the site id at params.php




return array(

  'siteId' => '23',

  'defaultPageSize'=>20,

);



and passing ALL queries like this in the controller :\




'criteria'=>array(

          'condition'=>"t.SiteId = '". Yii::app()->params['siteId'] . "'",

          'order'=>'SortOrder ASC',    

        ),



and there are over hundred of sql statements…

How do I write the “WHERE siteId = ‘’” built into the underlying models so the footprint is small?

Check out the last paragraph on this page (Default Named Scope):

http://www.yiiframework.com/doc/guide/1.1/en/database.ar#named-scopes