Use CodeIgniter Active Record to convert MySQL query -


can convert normal mysql query codeigniter update strcuture.

update game_rounds  set from_score = case when from_id = 2 65 else from_score end,     to_score = case when to_id = 2 65 else to_score end  round_id=5 

i tried update_batch not able find correct solution.

thanks in advance

$this->db     ->set('from_score', 'case when from_id = 2 65 else from_score end', false)     ->set('to_score', 'case when to_id = 2 65 else to_score end', false)     ->where('round_id', 5)     ->update('game_rounds'); 

$this->db->set() enables set values inserts or updates. can used instead of passing data array directly insert or update functions.

the optional third parameter ($escape), prevent data being escaped if set false.

ci active record class


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -