这是我的CActiveDataProvider查询。
$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);
这给了我0行。但是当我在mysql中使用相同的查询时,它会给我正确的结果。以下是相同的mysql查询
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
我尝试在CActiveDataProvider中将分页设置为1000,但这没有用。
$dataProvider= new CActiveDataProvider($model,array('criteria'=>$criteria,'pagination' =>array('pageSize'=>1000)));
即使我将分页设置为
false
,但仍然没有结果$dataProvider= new CActiveDataProvider($model,array('criteria'=>$criteria,'pagination' =>false));
最佳答案
您已将Parse error
放入$criteria->condition
(job.current_assigned="'.Yii::app()->user->id.'""
)
尝试用以下字符串替换它:
关于php - Yii 1:CActiveDataProvider不会返回所有记录,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35862430/