Welcome Guest, Not a member yet? Register   Sign In
Last ID in db
#3

[eluser]PhilTem[/eluser]
If you want to receive the last inserted ID (after an insert-query) you may also use

Code:
$last_id = $this->db->last_insert_id();

However, @Stefan's code works well for auto-incrementing tables. If you tend to use your own primary-key, you'd have to have a field which annotates the creation date or its time stamp by which you would sort DESC and limit it to (1,1) while selecting the primary-key field.


Messages In This Thread
Last ID in db - by El Forum - 04-28-2012, 03:13 AM
Last ID in db - by El Forum - 04-28-2012, 07:09 AM
Last ID in db - by El Forum - 04-28-2012, 07:59 AM



Theme © iAndrew 2016 - Forum software by © MyBB