Reputation: 3804
I have a PDO connection (persistent) and I am doing queries like this:
$sql=$pdo->prepare("SELECT * FROM table WHERE myindex=:PDO_myIndex");
$sql->bindParam(':PDO_myIndex', $myIndex);
$sql->execute();
The problem is $myIndex is INT before bindParam (confirmed with var_dump) and then it becomes STRING after bindParam (before the execute).
Is this a normal or known behavior ?
Upvotes: 0
Views: 37
Reputation:
Yes that is an issue, check manual comment.
The third parameter stands for datatype - you can use that one.
Upvotes: 1
Reputation: 46910
You can explicitly specify that using the third parameter available
$sql->bindParam(':PDO_myIndex', $myIndex, PDO::PARAM_INT);
^
Upvotes: 3