Ask a Question related to PHP Bugs, Design and Development.
-
phpbugs at filofox dot com #1
#40740 [NEW]: PDO::execute() errors when parameters are used in LIMIT clause
From: phpbugs at filofox dot com
Operating system: Linux Debian Sarge 3.1
PHP version: 5.2.1
PHP Bug Type: PDO related
Bug description: PDO::execute() errors when parameters are used in LIMIT clause
Description:
------------
The following emerged after upgrading from 5.2.0 to 5.2.1 and has been
checked in both versions: the error only occurs in 5.2.1 .
When passing parameters into a LIMIT clause using PDO::execute(), it
appears that PDO is quoting the parameters, which causes MYSQL to throw an
error.
FYI: PDO_MYSQL is built against MySQL client library 5.0.18.
Reproduce code:
---------------
$dbh = new PDO('mysql:localhost;dbname=my_db', 'user', '' );
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
try{
$query = $dbh->prepare( 'SELECT * FROM some_table LIMIT :start, :limit'
);
if ( $query->execute ( array ( 'start' => 0, 'limit' => 10 ) ) )
{
while ( $row = $query->fetch ( PDO::FETCH_ASSOC ) )
{
print_r($row);
}
$query->closeCursor();
}
} catch( Exception $e ){
print_r( $e );
}
Expected result:
----------------
A number of rows are returned.
Actual result:
--------------
An exception is thrown:
PDOException Object
(
[message:protected] => 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', '10'' at line 1
[string:private] =>
[code:protected] => 42000
[file:protected] => [my_file].php
[line:protected] => 19
[trace:private] => Array
(
[0] => Array
(
[file] => [my_file].php
[line] => 19
[function] => execute
[class] => PDOStatement
[type] => ->
[args] => Array
(
[0] => Array
(
[start] => 0
[limit] => 10
)
)
)
)
[errorInfo] => Array
(
[0] => 42000
[1] => 1064
[2] => 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', '10'' at line 1
)
)
--
Edit bug report at http://bugs.php.net/?id=40740&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40740&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40740&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40740&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=40740&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=40740&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=40740&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=40740&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=40740&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=40740&r=support
Expected behavior: http://bugs.php.net/fix.php?id=40740&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=40740&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=40740&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=40740&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40740&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=40740&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=40740&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=40740&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=40740&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=40740&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=40740&r=mysqlcfg
phpbugs at filofox dot com Guest
-
#39235 [NEW]: Permit parameters in execute()
From: mark dot 2391 at blueyonder dot co dot uk Operating system: Debian GNU/Linux PHP version: 5.1.6 PHP Bug Type: ... -
Using IN in a WHERE clause
I'm trying to use IN in a WHERE clause as follows: idx_res.city IN ('#session.s_city#') The value of session.s_city is 'highlands ranch, lone... -
CausesValidation=true causes callback to execute on errors in IIS 6.0 cluster
I'm having a weird issue with IIS 6.0 running in a 3 node cluster using server affinity and my ASP.Net request validator controls. My aspx page... -
Adobe Illustrator Errors : Exceed implementation limit
I do a work on adobe Illustrator 10 and save it in illustrator 9 format. Now i can open it anymore, receiving this error when i try to open it.... -
create parameters without creating parameters
cant you create ado command parameteres without creating a parameter object? i have a function that takes the name of a stored proc, and two...



Reply With Quote

