php - How to update a field with dynamic value that involves the current value of the field - using PDO
Get the solution ↓↓↓I have some records in mysql db that have a field by the name "num". Each record have an individual num value.
I what to add a value to each num field.
This simple query"UPDATE tbl SET num = num+22"
works just fine in phpMyAdmin.
BUT I need to write it in code and I'm using PDO. (it must be PDO).
So I wrote this code:
$sth = $dbh->prepare("UPDATE tbl SET num = num + ?");
$sth->bindValue(1, 22, PDO::PARAM_INT);
$sth->execute();
After run I got bad result - all num field got the same value in all records
What should I do ?
How can I make the =num field dynamic ?
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: err_ossl_pem_no_start_line
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.