Prepared Statement Error - Automatic Quotes
Posted: Wed Sep 02, 2009 2:35 pm
Hi all,
I'm trying to use PDO to execute MySQL statements, but I'm running into an issue... Here is the code:
The problem is that when I prepare the $sql statement, I expect the following:
SELECT * FROM product WHERE display = 1 OR display = 3 ORDER BY display DESC LIMIT 0, 4
What I actually get is this...
SELECT * FROM product WHERE display = 1 OR display = 3 ORDER BY display DESC LIMIT '0', '4'
The PDO prepare statement seems to be putting quotes around my integers, which causes errors in the MySQL execution. How can I stop it from doing this?
Thank you!
I'm trying to use PDO to execute MySQL statements, but I'm running into an issue... Here is the code:
Code: Select all
$sql = 'SELECT *
FROM product
WHERE display = 1 OR display = 3
ORDER BY display DESC
LIMIT :start_item, :products_per_page';
// Build the parameters array
$params = array(
':products_per_page' => PRODUCTS_PER_PAGE,
':start_item' => $start_item;
$statement_handler = $database_handler->prepare($sql);
// Execute the query
$statement_handler->execute($params);
// Fetch result
$result = $statement_handler->fetchAll($fetchStyle);
SELECT * FROM product WHERE display = 1 OR display = 3 ORDER BY display DESC LIMIT 0, 4
What I actually get is this...
SELECT * FROM product WHERE display = 1 OR display = 3 ORDER BY display DESC LIMIT '0', '4'
The PDO prepare statement seems to be putting quotes around my integers, which causes errors in the MySQL execution. How can I stop it from doing this?
Thank you!