Use a PHP function in a PDO prepared statement

Viewed 20

I am trying to update some records which uses a function, and the function's parameter accept's the columns current value.

For example, when doing an increment update query, I can do:

$query = $pdo->prepare("UPDATE tbl SET col1 = col1 + 1 WHERE id = someId");

Surely that works,

But how about some complicated computations, for example:

$query = $pdo->prepare("UPDATE tbl SET col1 = {someFunc(`col1`)} WHERE id = someId");

Now, this is not working, perhaps it passes the col1 as a literal col1 instead of col1's database value.

Thus, the question's title.

0 Answers
Related