ZF2 + Zend \ Db \ Sql \ Update, adding to the current value

I am trying to do something relatively simple, but I canโ€™t understand.

I just want to add to the current value in the database, one way or another, to make the equivalent:

UPDATE `tablename` SET fieldB = fieldB + 1 WHERE fieldA='X' 

Using the Zend / db update function?

+6
source share
1 answer

it will be something like this:

  $select = $sql->update(); $select->table('basket'); $select->set(['quantity' => new Expression("quantity + ? ", [$quantity])]); $select->where(['basket_id'=>$basket_id]); 

Remember to avoid / misinform the data! (for example, I do with $ quantity)

+6
source

Source: https://habr.com/ru/post/947999/


All Articles