I'd like to pass my PDO query parameters as an array to my execute() method, rather than using PDO's bindParams. I'm doing this so I can create one function to dynamically execute similar queries with differing numbers of parameters.
The bindParam() route yields the expected results:
$stmt->bindParam(":user_id",$user_id,PDO::PARAM_INT);
$stmt->bindParam(":n",$n,PDO::PARAM_INT);
$stmt->execute();
But this method returns an empty set with no errors thrown:
$params = array(":user_id"=>$user_id,":n"=>$n);
$stmt->execute($params);
Can someone explain to me what the difference between these two methods is, and what is causing my issue? The only difference I'm seeing is that when I pass $params as an argument to .execute, I'm not getting a chance to specify the type (POD::PARAM_INT). If that is the issue, is there a workaround for this?