Issue
I am trying to get sum of a column values in mysql table with the codeigniter query as
$this->db
->query("Select SUM(tb1.amount) from table1 tb1 inner join table2 tb2 on tb2.Id=tb1.Id Where tb2.Status='1'")
->result()
it give me error as array to string conversion I need just a number such count(amount) returns number of rows with num_row()
Solution
use as => $data['total']
$data = $this->db
->query("Select SUM(tb1.amount) as total from table1 tb1 inner join table2 tb2 on tb2.Id=tb1.Id Where tb2.Status='1'")
->row_array()
Answered By - Devsi Odedra
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.