I think $k
is undefined outside the foreach
loop
It's probably easier like this:
$statement = $this->connection->prepare(
"SELECT * FROM page WHERE folio_id IN(". $in .") AND content LIKE ?");
$values=$folioIds;
$values[]="%" . $q . "%";
if ($statement->execute($values)){
$rows=$statement->fetchAll();
}