Yii Model Tutorials

Yii Model Before Save

Before save method is called before the record saved in database. When we update record in table, Some fields are changed by default like record created date, record modified date etc. I wrote the sample code for record created and last modified.In Format 1, If $this->isNewRecord is return true, it is new record. Now “createddate” variable will get current date. If $this->isNewRecord is return false, It will affect “modifieddate” date […]... Read More »

FindAll In Yii

Yii Framework. I list out all types of find, findall conditions in yii framework. It will very helpful for us.Yii find() Yii findAll()Yii findAll() JoinYii Sql commandYii find() find() <?php $model = User::model()->find(); find() With Condition <?php $model = User::model()->find('userid=1 AND status="A"'); (OR) $model = User::model()->find( 'userid=:userId And status=:Status', array(':userId'=>1,':status'=>'A') ); find() Width Criteria <?php $criteria = new CDbCriteria; $criteria->condition='userid=1 AND status="A"'; $model = User::model()->find($criteria); (OR) $criteria=new CDbCriteria; $criteria->condition='userid=:userId AND status=:Status'; […]... Read More »