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
Post a Comment