Reputation: 2569
I want to write a query like
"Update table tbl_name set amount = amount + 100 where id = 10";
I found no documentation in CI Active Record library, Is it possible to do such query using acitve record?
Looking forward for your responses.
Upvotes: 0
Views: 41
Reputation: 4079
This is the model function:
function update($id) {
$this->db->set('amount', 'amount+100', FALSE)
$this->db->where('id ', $id);
$this->db->update('tbl_name');
}
You can read the CI Active Record here
Upvotes: 3
Reputation: 36531
you can do that by using $this->db->set();
try this
$this->db->set('amount', 'amount+100', FALSE)
$this->db->where('id ', '10');
$this->db->update('tbl_name');
Upvotes: 0