I am using model below in CodeIgniter to get the sum of a column:
public function b2c_totalsales()
{
$this->db->select_sum('total_price');
$result=$this->db->from('orders_b2c');
return $result;
}
and in the controller:
$data['total_sales']=$this->reports_b2c->b2c_totalsales();
and I am getting:
Severity: 4096
Message: Object of class CI_DB_mysqli_driver could not be converted to string
Filename: views/reports_b2c.php
where is the error?
You need to execute the query with get
:
$this->db->select_sum('total_price');
$result = $this->db->get('orders_b2c')->row();
return $result;