How to display image in CDetailView Yii Framework 1.0

This tutorial will help you to display the image in CDetailview widget of yii framework 1.0. We added a different funcitons in model.php to display the image with different methods like only image, image with link, image from database etc.View.php <?php $this->widget('zii.widgets.CDetailView', array( 'data'=>$model, 'attributes'=>array( array( 'name'=>'image', 'type'=>'raw', 'value'=>$model->image_tag(), ), array( 'name'=>'imagelink', 'type'=>'raw', 'value'=>$model->image_with_link(), ), array( 'name'=>'image_database', 'type'=>'raw', 'value'=>$model->showphoto_from_database(), ) ), )); ?> model.phpDisplay Image Only public function image_tag(){ return […]... Read More »

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 search. In addCondition i used DATE_FORMAT function to filter the result. <?php public function search() { $criteria=new CDbCriteria; // condition for >= single date if(!empty($this->from_date) && empty($this->to_date)) { $this->from_date=date('Y-m-d',strtotime($this->from_date)); $criteria->addCondition( "DATE_FORMAT(checkin_time, '%Y-%m-%d') >= '$this->from_date'" ); } […]... Read More »

Yii 1.0 Display Image Form Database

Before save the image into database, i created one ‘text’ field in mysql table to save the image code.We can show the image in CDetailview from database table of yii framework. Here i used showphoto_from_database() function to display the image from database. showproof_from_image_folder() is used to fetch uploaded image url from database and display.view.php <?php $this->widget('zii.widgets.CDetailView', array( 'data'=>$model, 'attributes'=>array( array( 'name'=>'photo_id', 'type'=>'raw', 'value'=>$model->showphoto_from_database(), ), array( 'name'=>'vproof_id', 'type'=>'raw', 'value'=>$model->showproof_from_image_folder(), ) ), […]... Read More »