The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/printthread.php 16 require_once



UserSpice
ID of a record I just added - Printable Version

+- UserSpice (https://userspice.com/forums)
+-- Forum: Miscellaneous (https://userspice.com/forums/forumdisplay.php?fid=28)
+--- Forum: Documentation (https://userspice.com/forums/forumdisplay.php?fid=30)
+--- Thread: ID of a record I just added (/showthread.php?tid=958)



ID of a record I just added - marciocaparica - 02-16-2018

Hello!

I want to set up a relational table. So I need to get the id of a record I just added and use it on another. What is the best way to get the ID of the record I just added to the database?

Thank you!

M!


ID of a record I just added - dan - 02-16-2018

right after you do your insert query, do
$id = $db->lastId();