-----------
loader
-----------
bl_no PK
bl_cbm
bl_value
table 2
-------------
cargo
-------------
awb_no
bl_no
awb_cbm
awb_value
*****************************
1 loader = has many cargo
*****************************
-----------------------------------------------------------------------------------
Objective:
= get the sum of cargo.awb_cbm and cargo.awb_value
= after that, display the following in cgridview
------------------------------------------------- | bl_no | bl_value | sum(cargo.awb_value) | Net | ------------------------------------------- | DD142 | 5000 | 3000 | 200 | -------------------------------------------------
same thing in CBM, get the diffrence of the loader.bl_cbm and cargo.awb_cbm
i use this query and im success to get all i need
SELECT a.*,
(SELECT SUM(b.cbm) as ccbm FROM cargo b
WHERE b.bl_no = a.bl_no
) as cbm_difference,
(SELECT SUM(b.awb_value) as selling FROM cargo b
WHERE b.bl_no = a.bl_no) NET
FROM loader a-----------------------------------------------------------------------------------
my problem is:
i dont now how to make a function that can query and display in cgridview, i dont know if this is right?
my relation model
-----------------------------------------------------------------------------------
Model : loader
public function relations()
{
return array(
"x" => array(self::HAS_MANY, "cargo", "bl_no",),
);
}-----------------------------------------------------------------------------------
please anyone can help T_T.... im tired to find out
thanks in advance, sorry for my english low...
Reinhard Navarro

Help












