$this->db->get_where only returns 1 row - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19) +--- Thread: $this->db->get_where only returns 1 row (/showthread.php?tid=66216) |
$this->db->get_where only returns 1 row - Ragwin - 09-21-2016 I have two records in table Person with Name_Alpha set to A (see attachment). In a model file I then have PHP Code: $query = $this->db->get_where('Person', array('Name_Alpha' => $alpha)); Where $alpha is 'A'. But it only returns 1 record. I don't get any other errors. I used $this->db->last_query() to display the SQL Code: SELECT * FROM `Person` WHERE `Name_Alpha` = 'A' That should return all rows. I'm at a loss. RE: $this->db->get_where only returns 1 row - zurtri - 09-21-2016 Hmm - that all looks correct. My thoughts are: 1. Maybe there is a control character in one of the rows? In this case try a WHERE `Name_Alpha` LIKE '%A%' query and see if you are given different results. 2. In your phpymyadmin (or whatever) run the raw query - what result do you get? RE: $this->db->get_where only returns 1 row - Abuhuraira - 09-22-2016 are you fetching data using $query->result(); to get all the results ? RE: $this->db->get_where only returns 1 row - Ragwin - 09-22-2016 (09-21-2016, 03:56 PM)zurtri Wrote: Hmm - that all looks correct. My thoughts are: Tried that and it returned 2 rows. I'm going to alter the query so it doesn't use Query Builder functions. I'm much happier writing out the full SQL statement and it might reveal what the issue is. RE: $this->db->get_where only returns 1 row - Ragwin - 09-22-2016 (09-21-2016, 03:56 PM)zurtri Wrote: Hmm - that all looks correct. My thoughts are: My bad. When my model was selecting all records it was returning PHP Code: $query->result_array(); But when I was selecting specific records it was returning PHP Code: $query->row_array(); Typo from me copying from the tutorial. RE: $this->db->get_where only returns 1 row - zurtri - 09-22-2016 Glad it got worked out! |