как я могу вычислить сумму двух столбцов таблицы MySQL, используя функцию?как здесь
в столбце «заказы», столбец 2, два столбца со значениями, столбец 1, «промежуточный итог», столбец 2, «описания», как я могу сделать это для суммирования двух столбцов?
publicfunction count_gainliquid () {// ganho liquido
$this->ci->db->where('status', '1');
$count = $this->ci->db->get('orders');
$processbar = (1000 * $count->num_rows());
$total = 0;
foreach ($count->result() as $row) {
$this->ci->db->where('id', $row->id);
$orders = $this->ci->db->get('orders');
if ($orders->num_rows() > 0) {
foreach ($orders->result() as $ord) {
$total += $ord->subtotal;
}
}
}
return json_decode(json_encode(array('processbar' => $processbar, 'count' => $count->num_rows(), 'total' => number_format($total, 2, ",", ".") )));
}