Welcome Guest, Not a member yet? Register   Sign In
Problem with Last inserted record id
#5

[eluser]Joseph1982[/eluser]
[quote author="Colin Williams" date="1225192780"]So, does it return the id of the first of multiple inserts or the last? Once you know, you could iterate the difference to get all insert ids[/quote]

It will return the first id.

By using the $db->affected_rows(), we can find the total number of insertion and the last inserted is :

Code:
/** MySql function only returns the ID of the first record inserted, not the last one*/
        // Get the last record id inserted
        $last_insert_id        =    $this->db->insert_id();
        $affected_rows        =    $this->db->affected_rows();
        $affected_rows        =    $affected_rows -1;
        $last_seen_feed_item_id    =    $last_insert_id + $affected_rows;


This works in my case.

Thank you.


Messages In This Thread
Problem with Last inserted record id - by El Forum - 10-27-2008, 10:04 PM
Problem with Last inserted record id - by El Forum - 10-28-2008, 12:12 AM
Problem with Last inserted record id - by El Forum - 10-28-2008, 12:19 AM
Problem with Last inserted record id - by El Forum - 10-28-2008, 12:39 AM
Problem with Last inserted record id - by El Forum - 10-28-2008, 01:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB