In the database the id for this row is automatically generated. If an INSERT is executed in between the execute in this code and the SELECT I will get the wrong id returned. Is there a better alternative to getting the id and guaranteeing it will be from the row I inserted. I understand that the two statements will happen very close together but I would still like to know if there is a better way of doing this.
my $sthH = $dbh->prepare("INSERT INTO hardware (cpu_type, cpu_count, memory) VALUES (?,?,?)");
$resultH = $sthH->execute($cpu_type, $cpu_count, $memory);
$hardware_id = $dbh->selectrow_array("SELECT MAX(hardware_id) FROM hardware;");