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

[eluser]shaffick[/eluser]
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?

cheers
#2

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

I believe you need something like this.
#3

[eluser]shaffick[/eluser]
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.
#4

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

maybe this could work.
#5

[eluser]shaffick[/eluser]
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.
#6

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

[eluser]shaffick[/eluser]
edit: n/m. wrong info posted.




Theme © iAndrew 2016 - Forum software by © MyBB