CodeIgniter Forums
sum Multiplication quey - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: sum Multiplication quey (/showthread.php?tid=59426)



sum Multiplication quey - El Forum - 10-04-2013

[eluser]Unknown[/eluser]
can same body help me?


how do i implement this query mysql to codeigniter model

select sum(qty*price) as total from trans_report




sum Multiplication quey - El Forum - 10-04-2013

[eluser]CroNiX[/eluser]
Try
Code:
$totals = $this->db
  ->select('SUM(qty * price) as total', FALSE) //2nd parameter FALSE tells CI to not protect the identifiers, which it has problems with more complex stuff like this
  ->get('trans_report')
  ->result_array();