![]() |
DB count_all_results() is not returning an int but a string - 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: DB count_all_results() is not returning an int but a string (/showthread.php?tid=20813) |
DB count_all_results() is not returning an int but a string - El Forum - 07-22-2009 [eluser]jpi[/eluser] Hi, It's not a bug but the userguide is saying Code: $this->db->like('title', 'match'); I don't know for you, but I expect any count or count_all() method to return an integer. DB count_all_results() is not returning an int but a string - El Forum - 07-22-2009 [eluser]Phil Sturgeon[/eluser] Good point, they could do with typecasting this with a simple return (int) $x in the funciton. This is not really a coding fault of the EllisLab team, this is a shortfall of PHP's native MySQL binding functions. To these functions, EVERYTHING is a string, all the time. Useless! DB count_all_results() is not returning an int but a string - El Forum - 07-22-2009 [eluser]jpi[/eluser] Hum I am not sure... In the file db_active_rec.php line 1074 Code: if ($query->num_rows() == 0) And $query->num_rows() is built with php native function mysql_num_rows (in the mysql driver) which according to php doc returns an integer. DB count_all_results() is not returning an int but a string - El Forum - 07-22-2009 [eluser]Phil Sturgeon[/eluser] Ahh well ignore that then. Thought this was the same issue as selecting ints. Figured they would be doing select COUNT(*) which therefore gives a string. Next time I will double check ;-) |