Welcome Guest, Not a member yet? Register   Sign In
How to get id of last updated row
#1

[eluser]wasconet[/eluser]
I know i can use
Code:
$this->db->insert_id

to get the last insert, but it doesnt work for me.
#2

[eluser]sv3tli0[/eluser]
Check the documentation its into the first lines Smile

http://ellislab.com/codeigniter/user-gui...lpers.html
Code:
$this->db->affected_rows()
#3

[eluser]wasconet[/eluser]
Code:
$this->db->affected_rows()
returns the number of affected rows like 2 rows affected but i need the id of the affected row in this case just row row is updated and i need the id of that row.

Thanks
#4

[eluser]sv3tli0[/eluser]
Sorry, I misunderstand you.
There is no logical way to get affected ID.. It may be 0 , 1 or many..
Usually you update/delete using that id.. Perhaps you may catch it with select before updating..

Code:
SELECT id FROM table WHERE (updateWHEREcases)
and after it run the update..
#5

[eluser]jairoh_[/eluser]
in my experience that's not possible unless you specify the primary key.




Theme © iAndrew 2016 - Forum software by © MyBB