CodeIgniter Forums
Simple but quite annoying lol,about UPDATING data - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Simple but quite annoying lol,about UPDATING data (/showthread.php?tid=7982)



Simple but quite annoying lol,about UPDATING data - El Forum - 04-29-2008

[eluser]RaiNnTeaRs[/eluser]
hi all, how to get the old data value for updating records
for example,like in sql syntax

field = :old.field+1

how to do that in CI ?
This is my code, but it doesnt seem to work Sad

$updatedata = array
(
'no_urut' => 'no_urut'+1,
);
$this->db->from('dforum');
$this->db->where('dforum.no_urut','<'.$cek2);
$this->db->where('dforum.topic_id',$id2);
$this->db->update('dforum',$updatedata);


Thx


Simple but quite annoying lol,about UPDATING data - El Forum - 04-30-2008

[eluser]m4rw3r[/eluser]
All the ActiveRecord methods escape the data by default, so you have to use the AR set() method (which has a switch):
Code:
$this->db->set('no_urut', 'no_urut + 1', FALSE); // The false sets that no escaping will happen to that data (so no quotes added, but less security)
$this->db->where(’dforum.no_urut <’,$cek2); // the < must be in the key, not in the value
$this->db->where(’dforum.topic_id’,$id2);
$this->db->update(’dforum’);



Simple but quite annoying lol,about UPDATING data - El Forum - 05-05-2008

[eluser]RaiNnTeaRs[/eluser]
I've made my queries using classing sql syntax : 'update table set ...where .... '
I mean , is there anyway to use a simplified CI syntax to overcome this ? thx