mathi
mathi

Reputation: 107

yii csqldataprovider not getting full items from database

             $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);

If i run $sql query in mysql it will show 73 rows but when i do print_r $dataset it will show only 11 items in console......

Upvotes: 0

Views: 60

Answers (1)

Abbasi
Abbasi

Reputation: 617

count($provider->getData()) or print_r $dataset will display according to your pagination by default its 10. Either you can set pagination or remove it will work fine. When pagination is set false, this returns the same value as totalItemCount

Upvotes: 1

Related Questions