Welcome Guest, Not a member yet? Register   Sign In
Incrementing DB values
#4

I was finally able to get around to the use case where I needed to do this and here is what worked for me.

PHP Code:
$this->set('field''field + ' $this->db->escape($amount]), false)
    ->
where('id'$someId)
    ->
update(); 

The key here is that you have to use the set method and not pass the data into the update function. This allows you to use the third parameter to specify that you don't want it to escape the values. This does mean, however, that you have to escape any variable yourself as shown in this example.

I found this in the documentation at https://www.codeigniter.com/user_guide/d...ating-data under the information on the $builder->set() method.
Reply


Messages In This Thread
Incrementing DB values - by Derek - 11-12-2020, 04:54 PM
RE: Incrementing DB values - by InsiteFX - 11-13-2020, 01:20 PM
RE: Incrementing DB values - by wdeda - 11-13-2020, 03:20 PM
RE: Incrementing DB values - by Derek - 05-14-2021, 09:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB