echo Video::model()->count();
by using params: Video::model()->count('video_type <> :type', array('type' => $video_type);
using commandBuilder: Yii::app()->db->createCommand() ->select('COUNT(*)') ->from('video') ->where('video_type <> '.$video_type) ->queryScalar();
Monday, August 24, 2015
Yii count()
Saturday, August 22, 2015
yii Criteria date_format between
$lastmonth= date('Y-m-d', strtotime('today - 30 days')); $today= date('Y-m-d'); $criteria = new CDbCriteria; $criteria->addCondition( "DATE_FORMAT(create_date, '%Y-%m-%d') >='$lastmonth' and DATE_FORMAT(create_date, '%Y-%m-%d') <= '$today'" ); $criteria->limit = 10; $criteria->order = 'total_view DESC'; //$criteria->group = 'id'; $modelvideo= Video::model()->findAll($criteria);
Monday, August 17, 2015
Register function through clientScript->registerScript
Yii::app()->clientScript->registerScript('rightclick', " $('body').bind('contextmenu', function(e){ return false; }); ");
Tuesday, August 11, 2015
yii CStarRating displays and rating
$this->widget('CStarRating',array( 'name'=>'video_rating', // 'minRating'=>1, // 'maxRating'=>10, 'starCount'=>10, 'allowEmpty' => FALSE, 'value'=>$model->videorating($model->id), 'callback'=>' function(){ $.ajax({ type: "POST", url: "'.Yii::app()->createUrl('video/rating', array('id'=>$model->id)).'", data: "star_rating=" + $(this).val(), success: function(data){ $("#mystar_voting").html(data); }})}' ));
Wednesday, August 5, 2015
Yii homeUrl and baseUrl
Yii::app()->getBaseUrl(true); // => http://localhost/yii_projects Yii::app()->getHomeUrl(); // => /yii_projects/index.php Yii::app()->getBaseUrl(false); // => /yii_projects
Subscribe to:
Posts (Atom)