in reply to Inserting Select Array Material to MySql
Assuming uid is AUTO_INCREMENT try
my $sql = "INSERT INTO $table (uid,mid,qty) VALUES (NULL,?,?)"; my $sth = $dbh->prepare($sql); for (keys %medals){ if ( $medals{$_} > 0 ){ $sth->execute ($_ ,$medals{$_}); } }
LAST_INSERT_ID() will work for the first insert of the session because it will be 0, but subsequent inserts will fail as you try to enter another record with the same uid as the previous one.
poj
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Inserting Select Array Material to MySql
by typomaniac (Novice) on Sep 12, 2015 at 04:43 UTC |