2017-04-26 54 views

回答

0

您可以使用select_sum查詢構建器方法。

$total_quantity = 0; 

$row = $this->db->select_sum('quantity', 'total_quantity')->get('your_table')->row(); 

if (isset($row)) { 
    $total_quantity = $row->total_quantity; 
} 

$this->load->view('your_view', ['total_quantity' => $total_quantity]);