Christmas Bogus Bogus PHP PDO Bug

Posted on Wed, 10th January 2007 at 22:59 under Education, Coding

The 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 bogus reason:

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. Bogus! :(

Leave a Reply

You may also log in to post a comment.

XHTML:

If you want to <q>tag</q>, please balance these; a, i, em, b, strong, u, blockquote, q, ul, li, ol, abbr, code, pre, sub and sup.