CodeIgniter Forums

Full Version: Problem with sum result
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How's it going everyone!!!

I want to perform a sum, multiple columns.  I have this code, i don't know if is the correct way to do it:

PHP Code:
public function getTotalOrders($customer_id){
    return $this->selectSum('total''s_h''ship_cost''total')
                      ->whereIn('status', ['DV''DVW'])
                      ->where('YEAR(order_date) = YEAR(CURDATE())')
                      ->total; (<-- i think here is the problem)

PHP Code:
data = [
     'totalorders' => $orders->getTotalOrders($customer_id),

PHP Code:
<?= $totalorders?>

The problem is that codeigniter (4) doesn't show me any errors, but the in the view doesn't show any result.
I've tried another way like ->first(); ->find() ->findAll() and with those it showed me error. 
Also i tried to add like this
PHP Code:
$this->selectSum('SUM(total) + SUM(s_h) + SUM(ship_cost) AS 'total')
total s_h ship_cost', 'total') 

But still the same error or result.
I hope you can give me a hand with this!
Thanks in advance!