php - Codeigniter update record -
i have update record looks this
$data_gallery = array( 'order' => $value ); $this->db->where('order', $neworder); $this->db->update('gallery', $data_gallery);
i have say, 5 images have reorderd. have old position , new position.
but loop through sometime overwrite each other.
example:
5 images 1,2,3,4,5
i change order 2,1,3,4,5
i update in loop goes through array of new order.
update order = 2 order = 1 update order = 1 order = 2
obviously second 1 never gets hit order = 2 no longer exits.
i guess more logic question else.
any ideas how can loop through , update without losing of data? though maybe updating in batch operation didn't far it.
thanks in advance.
use image's id in clause:
$this->db->where('imageid', $imageid);
this set new order each image without overwriting (and disappearing!) information.
Comments
Post a Comment