hop of those help? You do not need to bind a literal character you have full control of. And binding is for actual parameters. Reserved words, operators, database identifiers... all these are not "bound" into the SQL statement. Since these would never come from user input, it makes no sense doing so.
$operator = '+';
$conn = $entityManager->getConnection();
$stmt = $conn
->prepare("UPDATE articles a SET a.position = a.position $operator 1")
$stmt = $conn
->executeQuery("UPDATE articles a SET a.position = a.position $operator 1");
Any of those help I'm getting this error : Number of variables doesn't match number of parameters in prepared statement every time I run this code: , Try putting all the parameters into one bindParam call:
should help you out I am trying to update 2 different tables using a transaction. For my first query I get the error "No data supplied for parameters in prepared statement". my second query goes through just fine. I know that the error refers to the variables being passed to the $stmt->bind_param(). I have checked, triple checked and can confirm that all the vars that I am passing to it actually contain values. I have also checked to make sure the value being passed is correctly indicated by an 's' or an 'i'. My question is do I have a syntax error that would give me this error message or is there any other suggestion as to how I can fix it? , Remove the single quotes around your placeholders. Replace
around this issue Turns out I was simply mistaken as to the function of exec(). (Too much Python?) exec() runs an external shell command, whereas what I was looking for was eval() which evaluates and runs any string inputted as PHP code.
Prepared Statement: Number of variables doesn't match number of parameters in prepared statement