Thursday, March 26, 2009

PHP PDO bug

Today i just tried to do a simple query 'SELECT * FROM content LIMIT 0, 15'. Since i have been extremely on PDO, i wrote the query in this way, 'SELECT * FROM content LIMIT :offset, :limit', $bind = array('offset'=>0, 'limit'=>15). I got this error:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''0', '15'' at line 1

And then i found this is a PHP bug: http://bugs.php.net/bug.php?id=40740&edit=2

Bug #40740 PDO::execute() errors when parameters are used in LIMIT clause

That is ok. For someone like me who uses PHP to an extreme extent, getting some PHP bugs is normal. I've seen another PDO bug before, which had been fixed. That bug only exists in one PHP release.

What really surprises me is submitted at 6 Mar 2007, while at the end of this bug report, i found this 'Still not fixed in the 5.2.8 release'. I am using 5.2.8!

No comments: