Created
December 31, 2013 04:14
-
-
Save ferlyz05/8192535 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* $sql = 'SELECT * | |
FROM pelanggan, ( | |
SELECT id_pelanggan, COUNT( id ) AS total_promo, SUM( jumlah_resi ) AS jumlah_resi, SUM( total_nominal ) AS total_transaksi | |
FROM `promo` | |
GROUP BY id_pelanggan | |
) AS x | |
WHERE id = x.id_pelanggan'; */ | |
$criteria = new CDbCriteria(); | |
$criteria->compare('customer.nama',$this->nama,true); | |
$criteria->compare('customer.nmr_identitas',$this->nmr_identitas,true); | |
$criteria->with = array('promos'=>array( | |
'alias'=>'x', | |
'select'=>'id_pelanggan, COUNT( x.id ) AS id, SUM( x.jumlah_resi ) AS jumlah_resi, SUM( x.total_nominal ) AS total_nominal', | |
'group'=>'id_pelanggan')); | |
$criteria->alias = 'customer'; | |
//$criteria->condition = 'customer.id = x.id_pelanggan'; | |
return new CActiveDataProvider('Pelanggan', array( | |
'criteria'=>$criteria, | |
'pagination'=>array( | |
'pageSize'=>20, | |
), | |
)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment