Welcome Guest, Not a member yet? Register   Sign In
Activerecord -> field=field+1

Hey guys,

I'm just wondering how to do an update and have

"update table set field=field+1"

i checked out the code for the mysql driver etc, it doesn't seem like i can do it through active records...anyone?


[eluser]Thorpe Obazee[/eluser]
$this->db->where('id', $this->tutorial_id);
$this->db->set('tutorial_views', 'tutorial_views + 1', FALSE);

I believe you need something like this.

yeah, that is correct. However, I have multiple fields to update and set doesnt take arrays.

Ah well, I'll just rework my code a bit. Thanks for the reply. If someone else has any ideas, shoot 'em my way.

[eluser]Thorpe Obazee[/eluser]
$array = array('name' => 'name + 1', 'title' => 'title + 1', 'status' => 'status + 1');
$this->db->set($array, FALSE);

maybe this could work.

I just had a quick glace: system/database/db_active_rec.php, line 974.

I don't think it does. My brain is fried right now anyway, will revisit this later.

Thanks for your help.

[eluser]Thorpe Obazee[/eluser]
haha. yeap me too... it's 4am here and I don't even know if I am still thinking straight.

agreed :p

edit: n/m. wrong info posted.

Theme © iAndrew 2016 - Forum software by © MyBB