I am having trouble with this query. This query results in the following error.
PDOException: SQLSTATE[HY093]: Invalid parameter number: no parameters were bound
$sql = "INSERT IGNORE table SET user_id = :uid";
if ($con = $connection->prepare($sql)) {
$con->bindValue(':uid', intval($this->uid), PDO::PARAM_INT);
$con->debugDumpParams();
$con->execute();
}
Parameters
Params: 1
Key: Name: [4] :uid
paramno=-1
name=[4] ":uid"
is_param=1
param_type=1
Query That works.
$sql = "INSERT IGNORE table SET user_id = :uid";
if ($con = $connection->prepare($sql)) {
$con->execute([':uid' => intval($this->uid)]);
}
Question Why can't I bind any parameter or value to the PDO prepared statement?
I am using Drupal 8 and I believe that their connections replace the PDO default driver.
executeunless you are usingblobs. It works very reliably. - Ryan Vincent