Please enable JavaScript to view this site.

Navigation: Advanced topics > Programming topics > Database API > Methods

Database API: LastId()

Scroll Prev Next More

 

Returns the last inserted autoincremented field value in the current connection.

Syntax

DB.LastId()

Arguments

No arguments.

Return value

Returns the last inserted autoincremented field value in the current connection.

 

 

dynamic data = XVar.Array();
data["make"]="Toyota";
data["model"]="RAV4";
data["price"]=16000;
DB.Insert("cars", data);
// get the ID of the inserted record and print it on the page
MVCFunctions.Echo(DB.LastId());

See also:

Database API: Insert()

Database API: LastError()

Database API: SetConnection()

Connecting to the database

About Database API