Articles Posted in the " Yii Model " Category

  • Yii SQL Query To CGridview

    CSqlDataProvider implements a data provider based on a plain SQL statement. This tutorial will help you to display the custom sql query result into cgridview as normal crud view.



  • Scenarios validation In Yii 1.0

    Scenarios validation is the one of the useful future in yii framwork and seperating the validation on any class derived from CModel. For example user registeration and updation will have different validation


  • Multiple Database Connection In Yii 1.0

    Yii have the multiple database connection by default. Yii components is used to make the relation between our models and database. To use the multiple database we have to configure the main.php file



  • DATE_FORMAT Search In Yii Framework 1.0

    This tutorial will help you to find the result using DATE_FORMAT() function. ‘DATE_FORMAT’ function is used to convert the integer to date format value. I add the source code for this type of date […]


  • Yii 1.0 Model Structure

    By default model classes are available within the 'protected/models' dirctory. Every class must be inherit from the CModel or subclass and we explained about yii 1.0 model structure


  • CDbDataReader

    CDbDataReader

    CDbDataReader reads the rows from a result. CDbDataReader Query <?php $cdbdatareader = Yii::app()->db->createCommand() ->select('username, password') ->from('usermaster') ->query(); ?> columnCount & rowCount <?php echo $cdbdatareader->rowCount; echo $cdbdatareader->columnCount; ?> CDbDataReader Using read(), next() <?php $record=$cdbdatareader->read(); echo […]


  • Yii createCommand Delete

    Yii createCommand Delete

    Functions function delete($table, $conditions='', $params=array()) The delete() method builds and executes a DELETE SQL statement.’$table’ is a table name of delete from.’$conditions’ and ‘$params’ is like where condition of delete statement Sample <?php $user=Yii::app()->db->createCommand() […]


  • Yii createCommand Update

    Yii createCommand Update

    Functions function update($table, $columns, $conditions='', $params=array()) Sample The update() method builds and executes an UPDATE SQL statement. <?php $user=Yii::app()->db->createCommand() ->update('tbl_user', array( 'username'=>'bsourcecode', ), 'user_id=:id', array(':id'=>1)); ?> OUTPUT SQL UPDATE `tbl_user` SET `username`=:username WHERE user_id=:id