$command=Yii::app()->db->createCommand(); $command->select('SUM(amount) AS sum'); $command->from('sale_info'); $command->where('user_id='.$_GET['users'].' AND ratingtyle="Initial"'); $command->andWhere('created_date>:start', array(':start' => $_GET['startdate'])); $command->andWhere('created_date<:end', array(':end' => $_GET['enddate'])); echo 'Initial Fee: '.$command->queryScalar();
Tuesday, December 30, 2014
Use BETWEEN AND Clause in Yii QueryBuilder
Sunday, December 28, 2014
CDbCriteria addBetweenCondition or filter by date range
// $criteria->addBetweenCondition($column, $valueStart, $valueEnd, 'AND'); $criteria = new CDbCriteria; $criteria->addBetweenCondition('actual_completion_date', $_GET['startdate'], $_GET['enddate'], 'AND'); $criteria->group = 'client_id'; $dataProvider = new CActiveDataProvider('SaleInfo', array( 'criteria' => $criteria, 'pagination' => array( 'pageSize' => 20, ), ) );
Monday, December 22, 2014
Invisible/hide rows in CGridView rowCssClassExpression
$this->widget('zii.widgets.grid.CGridView', array( 'id'=>'ordersort-grid', 'dataProvider'=>$dataProvider, 'rowCssClassExpression'=>'$data->dateleftint($data->order_id, $data->quantity, $data->order_date) >0?"row-open":"row-closed"', 'htmlOptions'=>array( 'class'=>'table table-striped table-hover table-bordered', ), 'columns'=>array( 'order_id', 'name', 'quantity', array( 'header' => 'Day Left', 'value'=>'$data->dateleft($data->order_id, $data->item_id, $data->quantity, $data->order_date)', 'type' => 'raw', 'cssClassExpression' => '"foo" . (2+3) ."bar"', ), array( 'name'=>'employee_id', 'header' => 'Employer', 'value'=>'($data->employee_id=="")? "Not Selected" : $data->Employerr->company_name', 'type' => 'raw', ), 'total', 'paid', 'due', 'active', 'paid_opt', 'process_by', 'process_date', array( 'class'=>'CButtonColumn', 'template'=>'{process}', 'buttons'=>array ( 'process' => array ( 'label'=>'Post job/adv', 'url'=>'Yii::app()->createUrl("order/jobpost", array("id"=>$data->id))', 'visible'=>'$data->dateleftint($data->order_id, $data->quantity, $data->order_date) > 0 ? true : false;' ), ), ), ), ));
Subscribe to:
Posts (Atom)