Welcome Guest, Not a member yet? Register   Sign In
how to use order by codeigniter
#1

(This post was last modified: 06-21-2017, 03:01 AM by kayinja.denis.)

am trying to use order by but i don't get all the results in table.
i have payment table 
Code:
payments={
          paymentid|academicID| studentID| invoiceID| amount
             1     |     1    |     1    |     1    |   2000  
             1     |     1    |     1    |     2    |    300  
             1     |     1    |     1    |     1    |     5  
             1     |     1    |     1    |     3    |    600
             1     |     1    |     1    |     3    |     10 

}
 and i have these two scripts
MY_model.php
PHP Code:
function get_order_by($array=NULL) {
 
       if($array != NULL) {
 
           $this->db->select()->from($this->_table_name)->order_by($this->_order_by)->where($array);
 
           $query $this->db->get();
 
           return $query->result();
 
       } else {
 
           $this->db->select()->from($this->_table_name)->order_by($this->_order_by);
 
           $query $this->db->get();
 
           return $query->result();
 
       }
    } 

action_helper.php
PHP Code:
function joide($array$value$key=NULL) {
 
   $returnArray = array();
 
   if(count($array)) {
 
       foreach ($array as $item) {
 
           if($key != NULL) {
 
               $returnArray[$item->$key] = strtolower($value) == 'obj' $item $item->$value;
 
           } else {
 
               $returnArray[] = $item->$value;
 
           }
 
       }
 
   }
 
   return $returnArray;

amount_m.php
PHP Code:
function get_order_by_amount($array=NULL) {
 
       $query parent::get_order_by($array);
 
       return $query;
 
   

controller.php

PHP Code:
$payments joide($this->amount_m->get_order_by_amount(['academicID' => $academicID]), 'obj''invoiceID');

$this->data['amount'] = $payments

so when i run  <?php dd($mummy) ?> i don't get all the results,  i mean it won't get the amount = 3 and 10 where invoiceid =1 and 3 respectively but it returns  the 2000, 3000 and 600, it seems it doesn't return the amount where invoiceID is the same like for 1 and 3
Reply


Messages In This Thread
how to use order by codeigniter - by kayinja.denis - 06-21-2017, 02:58 AM
RE: how to use order by codeigniter - by InsiteFX - 06-21-2017, 03:19 AM
RE: how to use order by codeigniter - by InsiteFX - 06-21-2017, 04:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB