i want to store 2 related record in 2 different table in mysql
i have these information
name, option1, option2
name and its id are store in users table and options are store in options table
the uid in this table is auto increment
users table
uid --- name
1 --- Jack
2 --- Sara
options table
user_uid --- option
1 --- aaa
1 --- bbb
2 --- ccc
2 --- ddd
the question is how can i find next uid in users table to save my options with that foreign key, there are several ways to get next generated id like
LAST_INSERT_ID()
or
mysql_insert_id()
or
$result = mysql_query("SHOW TABLE STATUS LIKE 'table_name'");
$row = mysql_fetch_array($result);
$nextId = $row['Auto_increment'];
but if several request coming to server in same time are these ways work ?
what if after i get last id, another record saved to db and change last id
is there any way to reserve next auto increment id and get that ?