Question

When using $db->sql_query in PHPBB3, how would I get the id of a row created with an insert statement?

Was it helpful?

Solution

Use:

SELECT LAST_INSERT_ID()

Reference:

OTHER TIPS

in phpBB3 you get an even better way, the dbal go a function for this: $db->sql_nextid():

$sql = 'INSERT INTO ' . USERS_TABLE . ' ' . $db->sql_build_array('INSERT', $user_ary);
$db->sql_query($sql);

$user_id = $db->sql_nextid();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top