Query returning different results in phpMyAdmin and CodeIgniter - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Query returning different results in phpMyAdmin and CodeIgniter (/showthread.php?tid=8668) |
Query returning different results in phpMyAdmin and CodeIgniter - El Forum - 05-27-2008 [eluser]Uriptical[/eluser] Hi all, In my model I have following function: Code: public function do_region_and_country_match($region_name, $country_name) It returns the following output: Quote:the query is: SELECT COUNT( timezone_countries.name ) AS countries_in_region FROM timezone_countries JOIN timezone_regions ON timezone_regions.id = timezone_countries.timezone_region_id WHERE ( timezone_regions.name = 'Africa' ) AND ( timezone_countries.name = '' ) The result, that being that the result is 1, is not correct. The correct result, however, is shown when I run the following query in phpMyAdmin: Code: SELECT COUNT( timezone_countries.name ) AS countries_in_region FROM timezone_countries JOIN timezone_regions ON timezone_regions.id = timezone_countries.timezone_region_id WHERE ( timezone_regions.name = 'Africa' ) AND ( timezone_countries.name = '' ) The result in phpMyAdmin is: Quote:countries_in_region Any ideas on what I've done wrong with the php code to get a result of 1 would be much appreciated. Query returning different results in phpMyAdmin and CodeIgniter - El Forum - 05-27-2008 [eluser]m4rw3r[/eluser] Ummm, you assign a 1 to $row->countries_in_region, I believe you want to use == . Query returning different results in phpMyAdmin and CodeIgniter - El Forum - 05-28-2008 [eluser]Uriptical[/eluser] Hmm, that was a rather obvious mistake. I've been writing too much Delphi code or at least that's my excuse. Thanks for your help. It's interesting that values can be assigned straight after an IF statement where a comparison between two values is normally made. I'm curious to know if there would be any coding situations where this feature would be used. Query returning different results in phpMyAdmin and CodeIgniter - El Forum - 05-29-2008 [eluser]m4rw3r[/eluser] Code: if($node = $this->MPTtree->xpath(array('about','me'))){ Or, you could write it like this: Code: $node = $this->MPTtree->xpath(array('about','me')); |