#35801 [Opn->Fbk]: Prepared statement with "LIMIT :limit"
ID: 35801
Updated by: sniper@php.net
Reported By: brice dot joly at free dot fr
-Status: Open
+Status: Feedback
Bug Type: PDO related
Operating System: Windows XP
PHP Version: 5.1.1
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5.1-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5.1-win32-latest.zip
Previous Comments:
------------------------------------------------------------------------
[2005-12-25 13:21:11] brice dot joly at free dot fr
Description:
------------
As of MySQL 5.0.7, placeholders can be used in the LIMIT clause when
using prepared statements
(http://dev.mysql.com/doc/refman/5.0/en/select.html). Will this feature
make it to PDO?
Friendly input: array(':limit' => 10) as well as "pager" input
array(':limit' => array(10, 10)) would make sense for the MySQL driver
since it understands both syntaxes.
Reproduce code:
---------------
Prepared SQL query:
SELECT * FROM table LIMIT :limit
with bindParam(':limit', 10), prepared statement sent to DB will be:
SELECT * FROM table LIMIT "10"
Expected result:
----------------
Double quotes on LIMIT value will raise a MySQL Error 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 '"10"' at line 1.
Of course MySQL expects
SELECT * FROM table LIMIT 10
Actual result:
--------------
Apache crashes, log reads:
Parent: child process exited with status 3221225477 -- Restarting.
No Exception/PHP Error, tested on WinXP, Apache/2.0.52, PHP 5.1.1,
MySQL 5.0.17
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35801&edit=1
Thread (4 messages)