Issue with joining tables. - 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: Issue with joining tables. (/showthread.php?tid=71527) |
Issue with joining tables. - HarrysR - 08-24-2018 Hey guys, I know it might be a silly question but i can't make it work and it drives me crazy. I have a view.php for displaying single item details. In model file i'm trying to join some tables (in which some columns are INT and have 0 value). When I'm trying to get a single entry where the INT column is 0, i can't get any info shown in the "view.php" file (if i also place the show_404 if data are empty i get redirected. Which means that it does not get any data). When i erase the db join it works fine. My guess is something i made wrong with the db or the model. Any ideas?! Controller Code: public function view($pet_entry_id = NULL, $pet_entry_slug = NULL){ Model file Code: public function get_pets($pet_entry_id = 0, $pet_entry_slug = FALSE){ Thank you in advance! RE: Issue with joining tables. - jreklund - 08-25-2018 I can't see that you are converting $pet_entry_id into an integer. It will be a string of '0' so the following will not be true. PHP Code: if($pet_entry_id === 0 && $pet_entry_slug === FALSE ){ RE: Issue with joining tables. - HarrysR - 08-25-2018 (08-25-2018, 05:31 AM)jreklund Wrote: I can't see that you are converting $pet_entry_id into an integer. It will be a string of '0' so the following will not be true. The problem is not the Pet_entry_id.. The problem is when the breed (which is optional) gets a zero value. If the value is different and not 0 them it works fine. I dont want that though, since as i mentioned is optional RE: Issue with joining tables. - HarrysR - 08-25-2018 I solved it by creating a value in the db of id number 1 (for no value) since the problem was that the 0 value i was joining with the other table could not be found. If anyone has any other solution to this feel free to explain! Thank you! |