Skip to main content

Posts

Showing posts from November, 2011

PHP PDO LIMIT

Had an issue with PDO and MySQL SELECT statement while using LIMIT in it. It threw an exception while I tried to bind the parameter like I normally do. $pdo = $db->prepare("SELECT * FROM table LIMIT :limit"); $pdo->bindValue('limit', $limit, PDO::PARAM_INT) $pdo->execute(); From here I found a solution. It is necessary to cast the parameter $limit. Like this.. $pdo->bindValue('limit', (int) $limit, PDO::PARAM_INT)