This seems to be a php bug : PDO ignores the PARAM_INT constant and use the $limit
and $limitvalue
variables as string. Which are quoted in the query when bound.
Try using :
$sql->bindParam(1, (int)$limitvalue, PDO::PARAM_INT);
$sql->bindParam(2, (int)$limit, PDO::PARAM_INT);
To force the variables type to int.