php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35801 Prepared statement with "LIMIT :limit"
Submitted: 2005-12-25 13:21 UTC Modified: 2005-12-25 20:33 UTC
From: brice dot joly at free dot fr Assigned:
Status: Not a bug Package: PDO related
PHP Version: 5.1.1 OS: Windows XP
Private report: No CVE-ID: None
 [2005-12-25 13:21 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-25 17:34 UTC] sniper@php.net
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


 [2005-12-25 18:38 UTC] brice dot joly at free dot fr
Tried with snapshot: no more Apache crash.

Yet LIMIT placeholder is still not supported, could someone possibly forward the feature request to Wez/anyone working on PDO? I think that would be a welcome addition. Thanks.
 [2005-12-25 20:34 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Limit statements cannot be part of prepared statements.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 30 08:01:30 2024 UTC