php - MySQL Auto Increment No Duplicate -


if run below query use auto_increment variable post table1 right afterwards, chances 2 users run query @ same time , obtain identical auto increment values?

is unlikely happen?

$query = "select auto_increment                information_schema.tables               table_schema = 'db1'               ,   table_name   = 'table1'";  $result =  $link->query($query); $numrows = mysqli_num_rows($result);  while($var2 = mysqli_fetch_array($result)) {     $autoincr = $var2['auto_increment']; }    $query = "insert table1(id,firstname)           values('$autoincr','$firstname')"; 

rather like

create table table1 (    id int auto_increment primary key,   fullname varchar(100) not null ); 

then in inserts

insert table1 (fullname) values('fred smith'); 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -