noncent / pdo_class_wrapper

A Class for PDO Wrapper
25 stars 21 forks source link

[Question] Update incremental value #12

Closed rumplin closed 3 years ago

rumplin commented 3 years ago

Hello,

how would I use the update method for incremental values?

example: UPDATE table SET value = value +1 WHERE id = 1;

This doesn't work as expected: $db->update("table", array("value "=>"value + 1"), array("id"=>(int)$id));

SQLSTATE[HY000]: General error: 1366 Incorrect integer value: 'value + 1' for column 'value' at row 1: update - table: 711

noncent commented 3 years ago

Hi @MokraCota , You can try with $db->pdoQuery("UPDATE table SET value = value +1 WHERE id = 1");

rumplin commented 3 years ago

Thank you. I am using this now. Just wanted to know if there is another way, with arrays.

noncent commented 3 years ago

PDO Class Wrapper was designed to keep noobs in mind so that they can avoid the hassle of understanding the PDO syntax. It's clean, memorable and easy to use. Hence new audience is asking to add some complex methods, I will try to serve in a very simpler way.