I am using PHP with PDO for PostgreSQL. I am getting weird behavior when I try to bind a specific value into my query. What I have is the following:
$value[0][$i] = "'%{$filtervalue}%'";
$values[] = & $value[0][$i];
$result = $pdo->prepare($query);
$result->bindValue(':condition', $values[0]);
$result->bindValue(':starts', $start);
$result->bindValue(':pagesize', $pagesize);
Now the $query parameter returns back
SELECT orderDate, shippeddate, shipName,
shipaddress, shipcity, shipcountry
FROM orders WHERE ( shipcity LIKE :condition )
LIMIT :pagesize OFFSET :starts
which is exactly what I want. However the issue is with the $vales[0] parameter because $pagesize and $start work fine.
When I execute with the $vales[0] parameter the results returns back nothing.
However, when I change
$result->bindValue(':condition', $values[0]);
To
$result->bindValue(':condition', '%Bern%');
it works for that particular condition and the results are shown.
I doubled checked to make sure $values[0] returns back '%Bern%' and it does.
I even checked to see the type is string and it is.
I even added PDO::PARAM_STR and still nothing.
I ran out of ideas on why it isn't working.