I have a problem with displaying a bunch of data from my database. Getting data from many tables.
My query before was getting all the data in one query then I had managed to find a way on how to optimize it but I'm not satisfied.
foreach($query->result_array() as $row ){  
   $drreturn = $this->getDRReturnAmount($row["idno"],$date1);
   $return_amount[] = $drreturn->return_amount;
   $checkDRServiceNoPayment = $this->checkDRServiceNoPayment($row["idno"],$date1,$date2);
   if($checkDRServiceNoPayment->num_rows() > 0) {
    $minus_item_amount[] = 0;
   $getProductPurchase = $this->getProductPurchase($row["idno"],$date1,$date2);
    $minus_item_amount[] = $getProductPurchase->amount;
            }
        }
btw I'm using datatable. what I did before was I didn't use an array and I put the model functions inside the foreach but it seems that nothing happened even tho I used array.
 
    