Issue with joining tables. |
08-24-2018, 03:11 PM
(This post was last modified: 08-24-2018, 03:13 PM by HarrysR. Edit Reason: Added the 404 issue too.. )
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! //Life motto if (sad() == true) { sad().stop(); develop(); }
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 ){ (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 //Life motto if (sad() == true) { sad().stop(); develop(); }
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! //Life motto if (sad() == true) { sad().stop(); develop(); } |
Welcome Guest, Not a member yet? Register Sign In |