Welcome Guest, Not a member yet? Register   Sign In
How do I get the autoincremented ID of the latest inserted row.
#1

(This post was last modified: 10-15-2022, 10:55 PM by davecoventry.)

My code:
PHP Code:
    $this->db->simpleQuery('Use D'.$id);
    $this->db->table('drawings')->insert(array("name"=>$fname));
    return $this->db->insertID(); 

This returns a model object, but I need the number of the ID.
if I use
PHP Code:
$this->db->insert_id(); 

I get an error which says that insert_id() is an undefined method.

Code:
+----------+--------------+------+-----+---------------------+----------------+
| Field    | Type        | Null | Key | Default            | Extra          |
+----------+--------------+------+-----+---------------------+----------------+
| id      | int(9)      | NO  | PRI | NULL                | auto_increment |
| name    | varchar(255) | YES  |    | NULL                |                |
| revision | char(3)      | NO  |    | NULL                |                |
| date    | timestamp    | NO  |    | current_timestamp() |                |
+----------+--------------+------+-----+---------------------+----------------+
~ Dave
Reply


Messages In This Thread
How do I get the autoincremented ID of the latest inserted row. - by davecoventry - 10-15-2022, 01:14 PM



Theme © iAndrew 2016 - Forum software by © MyBB