Christmas Bogus Bogus PHP PDO Bug
Posted on Wed, 10th January 2007 at 22:59 under Education, CodingThe following code works on Linux (3 rows returned) but not on Windows, which returns a SQL syntax error citing LIMIT "0", "3". See PHP bug 35801 closed as “bogus” by an idiot on Christmas Day 2005 for the
Limit statements cannot be part of prepared statements.
Anyone care to confirm?
<?php
define( 'DB_USER', 'root' );
define( 'DB_PASSWORD', 'password' );
$sql = 'SELECT * FROM TABLES LIMIT ?,?';
$params = array( 0, 3 );
try {
$dsn = 'mysql:dbname=INFORMATION_SCHEMA;host=localhost';
$link = new PDO( $dsn, DB_USER, DB_PASSWORD );
if( $stmt = $link->prepare($sql) and $stmt->execute($params) ) {
$results = $stmt->fetchAll();
echo count($results).' rows returned';
} else
echo $stmt->errorInfo();
}
catch( PDOException $ex ) {
die( 'Connection failed: '.$ex->getMessage() );
}
?>
This is hurting someone I love.