I have the following MY-SQL query in CodeIgniter and I am trying to get the multiplication of [sub_product_price]*[quantity] and display it as a multiply.Any one can help me with it . I went through the CodeIgniter User Guide and I could not find anything to related this.
Thanks!!!!
function product_profit_chart(){
$this->db->select(array(
'tbl_sub_products.sub_product_name',
'tbl_sub_products.sub_product_id',
'tbl_sub_products.sub_product_price',
'SUM(tbl_order_products.quantity) as quantity'
));
$this->db->from('tbl_order_products');
$this->db->join('tbl_order_product_details', 'tbl_order_product_details.order_id=tbl_order_products.order_id','LEFT');
$this->db->join('tbl_sub_products', 'tbl_sub_products.sub_product_id=tbl_order_products.product_id','LEFT');
$this->db->group_by('tbl_sub_products.sub_product_id');
$this->db->where('tbl_order_product_details.order_status', 'completed');
$query = $this->db->get();
return $query->result();
}
return array of the above query.
[1] => stdClass Object
(
[sub_product_name] => chocolate cake 500G
[sub_product_id] => SP001
[sub_product_price] => 1000.00
[quantity] => 14
)
[2] => stdClass Object
(
[sub_product_name] => Sausage Bun
[sub_product_id] => SP002
[sub_product_price] => 50.00
[quantity] => 16
)
$this->db->from()is for. - Bankzilla