Yii beforeFind()与afterFind()用法


刚开始接触yii时没弄明白这两个方法是如何工作的,今天遇到一个问题,需要使用,又仔细看了一下。简单记录一下用法。

<pre class="lang:php decode:true " >    public function beforeFind(){
        parent::beforeFind();
        $this-&gt;dbCriteria-&gt;condition='field=1';
    }
</pre> 
<pre class="lang:php decode:true " >    public function afterFind(){
        parent::afterFind();
        $this-&gt;title="&lt;h1&gt;{$this-&gt;title}&lt;/h1&gt;";
    }</pre> 

Archives