Using CI update_batch(), I am unable to set a value where I increment an integer db value. This works successfully with CI set(); update(), but batch is the better option as there are multiple updates.
I have columns that all have the same characters at the end of the name, with different characters at the beginning (different years): 2014x , 2015x , 2016x , etc. So I have created a $var that identifies the year, then I add the string 'x' and 'y' via concatenation. Finally, the value setting in the array is to increment by 1 so I add +1 . This concatenation works fine in the keys - that is to say I am updating the correct column and fields.
$data = array(
array('name' => $name1,
$var.'x' => $var.'x+1'),
array('name' => $name2,
$var.'y' => $var.'y+1')
);
$this->db->update_batch('my_table', $data, 'tname');
In the above case, the fields are updated with the value of only $var - the year that has been defined.
I have also tried the following:
=> '{"$var.x+1"}' // places a '0' value in the field
=> $var.'x' +1 // places the value of $var
=> '$var.x+1' // places a '0' value in the field
How can I use update_batch() to increment my field by 1?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire