This is one more on the LIMIT clause and PDO, but I could not find a solution elsewhere.
I'm getting a PDO error and I know perfectly well why.
PDO requires an integer on LIMIT clause, but as the variables are included as part of the given parameter array, PDO treats all of it as string, hence the error.
The question is: how can I set this up to avoid the error?
For general information, this is part of a " load more " set up.
SQLSTATE[42000]: Syntax error or access violation
This is the query:
$param=array();
$param = array_merge($param,$geocities);
$param[] = $limit;
$param[] = $offset;
$in = str_repeat('?,', count($geocities) - 1) . '?';
$sql = "SELECT ads.*, cities.city FROM ads
INNER JOIN cities USING(city_id)
WHERE cities.city_id IN ($in)
AND ads.published IS NOT NULL
AND ads.deleted IS NULL
ORDER BY ad_id
LIMIT ?
OFFSET ?";
$stmt = $ulink->prepare($sql);
$stmt->execute($param);