php - How to update a field with dynamic value that involves the current value of the field - using PDO ← (PHP, MySQL)

one text

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 ?

Source