Welcome Guest, Not a member yet? Register   Sign In
Simple but quite annoying lol,about UPDATING data
#1

[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
#2

[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’);
#3

[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




Theme © iAndrew 2016 - Forum software by © MyBB