Pergunta

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

Foi útil?

Solução

Use:

SELECT LAST_INSERT_ID()

Reference:

Outras dicas

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();
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top