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)
Comments
Post a Comment