I have

$result = db_query($strSQL) or die ("Error while testing if there is already a record in the Entries table");

Where $strSQL is an insert statement

How do i get the last inserted Id in Drupal 7 as I gather db_last_insert_id() does exist anymore

Is it

$Id =InsertQuery::execute();

Thanks

Comments

An idea

Hello,
Are using an SQL database and a numeric key (which is incremented)? If so, then why not just do a logical (pseudo code) "select max(KEY_VAL) from TABLE".

Hope that helps :)

Thinking is the best way to travel.

If you use db_insert(), it

If you use db_insert(), it will return the id value used for the key field.

Thanks

Thanks I will change it to db_insert

Please mark as [SOLVED]

Hello,
Please edit your original post's subject. Add "[SOLVED]" to either the begin or end of the subject line. That way other folks can find the solution :)

Thinking is the best way to travel.

nobody click here