Here is my CActiveDataProvider query.
$startDate='2016-02-28';
$endDate='2016-03-05';
$criteria= new CDbCriteria();
$criteria->with=array('job','job.serviceType');
$criteria->order='t.uploaded_date DESC';
$criteria->select='t.id,t.job_master_id,t.image_path,t.image_name,t.uploaded_date';
$criteria->condition="SUBSTRING_INDEX(t.`image_name`,'.',-1) in ('jpg','jpeg','png','gif','JPG','PNG','GIF','JPEG') and job.trade_company_id='".Yii::app()->user->getState('TradeCompanyId')."' and job.current_assigned='".Yii::app()->user->id."'";
$criteria->addBetweenCondition('DATE(uploaded_date)', $endDate, $startDate);
This gives me 0 rows. but when i use same query in mysql it gives me proper result. following is same mysql query
SELECT `t`.`job_master_id`
FROM `media` `t`
LEFT OUTER JOIN `job_master` `job` ON ( `t`.`job_master_id` = `job`.`id` )
INNER JOIN `service_type_master` `serviceType` ON ( `job`.`service_type_id` = `serviceType`.`id` )
WHERE (
(
SUBSTRING_INDEX( t.`image_name` , '.' , -1 ) IN ( 'jpg', 'jpeg', 'png', 'gif', 'JPG', 'PNG', 'GIF', 'JPEG')
AND job.trade_company_id = '7' AND job.current_assigned = "14"
)
AND (
DATE( uploaded_date ) BETWEEN '2016-02-28' AND '2016-03-05'
)
)
ORDER BY `t`.`uploaded_date` DESC
I tried setting pagination to 1000 in CActiveDataProvider but this nothing works.
$dataProvider= new CActiveDataProvider($model,array('criteria'=>$criteria,'pagination' =>array('pageSize'=>1000)));
even i set pagination to false but still no result
$dataProvider= new CActiveDataProvider($model,array('criteria'=>$criteria,'pagination' =>false));
You have
Parse errorinto your$criteria->condition(job.current_assigned="'.Yii::app()->user->id.'"")Try to replace it with this string: