yii, handling image uploads

In Model file function rules() : <?phparray(‘product_image_1, product_image_2, product_image_3’, ‘file’, ‘types’=>’jpg, gif, png’, ‘allowEmpty’=>true),?> In View file set form like this : <div class=”form”><?php $form=$this->beginWidget(‘CActiveForm’, array( ‘id’=>’products-form’, ‘enableAjaxValidation’=>false, ‘htmlOptions’=>array(‘enctype’ => ‘multipart/form-data’))); ?> <p class=”note”>Fields with <span class=”required”>*</span> are required.</p> <?php echo $form->errorSummary($model); ?> <div class=”row”> <?php echo $form->labelEx($model,’product_name’); ?> <?php echo $form->textField($model,’product_name’,array(‘size’=>60,’maxlength’=>255)); ?> <?php echo… Continue reading yii, handling image uploads

YII, my sample model for search with relataionship

A model file for yii which has search fucntion which searches using relation ship: <?php/** * This is the model class for table “sf_category_slider”. * * The followings are the available columns in table ‘sf_category_slider’: * @property integer $rec_id * @property integer $cat_id * @property string $brand_id * @property string $slider_image * @property string $slider_link… Continue reading YII, my sample model for search with relataionship

mysql, import sql file from command line

Method 1: A quick way to duplicate MySQL databases is to do the following: Step 1: Dump the database either through PHPMyAdmin’s export form or through mysqldump (as I mentioned above). Note (usually, it’s mysqldump <database-name> -h<hostname> -u<username> -p<password> if you ommit the -h switch it will default to “localhost”). After you enter the command… Continue reading mysql, import sql file from command line

yii, best way to call jquery, js and css files

Yii, Best pratice to include jquery, js and css files : <?php Yii::app()->clientScript->registerCoreScript(‘jquery’); ?><?php Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl.’/css/style.css’);?><?php Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.’/js/star_rating.js’);?>