$sql= "SELECT p.id, p.item_name, p.status, p.img_1, p.date_created
FROM user_posted_assets p
WHERE `p`.`status` = 'AVAILABLE'
ORDER BY `p`.`date_created` DESC";
$sql_count="SELECT count(*), p.id, p.userid, p.img_1,p.date_created, p.date_lastmodified FROM user_posted_assets p
WHERE `p`.`status` = 'AVAILABLE'
ORDER BY `p`.`date_created` DESC";
// Get the count for
$count=Yii::app()->db->createCommand($sql_count)->queryScalar();
$dataProvider=new CSqlDataProvider($sql, array(
'totalItemCount'=>$count
));
$dataset = $dataProvider->getData();
header('content-type: application/json');
echo CJSON::encode($dataset);
如果我在mysql中运行$ sql查询,它将显示73行,但是当我执行print_r $ dataset时,它将只显示控制台中的11个项目......
答案 0 :(得分:1)
count($provider->getData())
或print_r $dataset
将根据您的分页显示为10.您可以设置分页或删除它将正常工作。当分页设置为false时,将返回与totalItemCount