Yii Framework Forum: Help With Cdbcriteria And Cactivedataprovider - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Help With Cdbcriteria And Cactivedataprovider Help with CDbCriteria and CActiveDataProvider Rate Topic: -----

#1 User is offline   vdnguyen 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 12-March 13

Posted 18 July 2013 - 10:47 AM

Hi all

when i used CDbCriteria and CActiveDataProvider to select 2 table and used CGridView to load data, my question is why there are no data in column of Total and Quantity , someone help me please.

thanks


controller
$criteria=new CDbCriteria;
$criteria->select = 't.Pro_ID,sum(p.Sales_Price) AS Total,sum(p.Sales_Quan) AS Quantity';
$criteria->join = 'LEFT JOIN Sales_Detail p ON t.Ph_ID = p.Ph_ID';
$criteria->group= 't.Pro_ID';

$data2table=new CActiveDataProvider('Phones',array(
            'criteria'=>$criteria,
            'pagination'=>array(
                'pageSize'=>2,
            ),
        ));
        
$this->render('index',array(
                'data2table'=>$data2table,
)); 



view
$this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'ph-grid-providers',
    'dataProvider'=>$data2table,
    'columns'=>array(
        'Pro_ID',
        'Total',
        'Quantity',
    ),
)); 

0

#2 User is offline   CeBe 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 534
  • Joined: 16-July 10
  • Location:Berlin. Germany

Posted 18 July 2013 - 10:49 AM

Have you added Total and Quantity as a property of your activerecord class?
0

#3 User is offline   vdnguyen 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 12-March 13

Posted 18 July 2013 - 11:24 AM

View PostCeBe, on 18 July 2013 - 10:49 AM, said:

Have you added Total and Quantity as a property of your activerecord class?




ok. it worked, much appreciate :lol:
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users