0

When I try to run the follow query it never returns anything, it just keeps running. What am I doing wrong with it?

$this->db->distinct('customer.Name')
                    ->from('customer')
                    ->from('invoicelinedetail')
                    ->from('invoice')
                    ->from('iteminventory')
                    ->where('invoice.CustomerRef_ListID = customer.ListID')
                    ->where('invoicelinedetail.IDKEY = invoice.TxnID')
                    ->where('invoicelinedetail.ItemRef_ListID =', $id)
                    ->order_by('customer.Name', 'desc');
$query = $this->db->get();
Jeremy Jackson
  • 2,247
  • 15
  • 24
  • I don't think `distinct()` takes any parameters. I think you need to do: `->distinct()->select('customer.Name')`. I'm also unsure if you can call `->from()` multiple times, try `->from('customer, invoicelinedetail, ...')` or use `->join()`. I could be 100% wrong, though. – gen_Eric Jun 14 '14 at 02:59
  • Also, what does "t just keeps running" mean? Do you mean the page never loads in your browser? – gen_Eric Jun 14 '14 at 03:01
  • a model method mut return something aswell :) try using return on the query to see that it returns an object. use @Dan's answer below to to extract what you want. – Patrick Jun 14 '14 at 06:34
  • I'm actually getting inconsistent data with models somehow. I'm trying it a different way now though. Rocket Hazmat: Exactly. The page never loads. – Jeremy Jackson Jun 14 '14 at 17:17

1 Answers1

0

After $this->db->get(); you need to retrieve your results

More info from CI Docs

To do this, set $query= to one of the following:

$this->db->result_array(); //returns array
$this->db->row_array(); //returns single row as array

$this->db->result(); //returns object
$this->db->row(); //returns single row as object
Dan
  • 9,391
  • 5
  • 41
  • 73