I have spent all day on this so hopefully someone can spot the issue.
If I start with how it was and can show you the results
$limitClause .= " " . $field_name . " " . $operator . " '" . $keyword . "%'";
$query = str_replace('{limit clause}', $limitClause, $query);
$r=$conn->prepare($query);
$r->bindParam(':fieldName', $field_name);
$r->bindParam(':operator', $operator);
$r->bindParam(':keyword', $keywordb);
$r->execute();
When I echo $r out I get this -
echo ($r->queryString);
WITH LIMIT AS ( SELECT *, ROW_NUMBER() OVER (ORDER BY ID) AS 'RowNumber' FROM Intranet WHERE Contract_Number like 'DOM%') select COUNT(*) from LIMIT WHERE Contract_Number like 'DOM%'
That works fine, its when I then start using pdo that things stop working
Change it to -
$limitClause .= " :fieldName :operator :keyword";
$query = str_replace('{limit clause}', $limitClause, $query);
$keywordb = $keyword."%";
$r=$conn->prepare($query);
$r->bindParam(':fieldName', $field_name);
$r->bindParam(':operator', $operator);
$r->bindParam(':keyword', $keywordb);
$r->execute();
echo ($r->queryString);
I get which looks right
WITH LIMIT AS ( SELECT *, ROW_NUMBER() OVER (ORDER BY ID) AS 'RowNumber' FROM Intranet WHERE :fieldName :operator :keyword) select COUNT(*) from LIMIT WHERE :fieldName :operator :keyword
But I dont get any results at all, it just doesnāt seem to recognise the binding, and so nothing appears