When it comes to updating it alwasy about the last game of the txt file and never the rest of them?my ($gamename, $gamedesc, $gamecount); my $select = $dbh->prepare( "SELECT count(*) FROM games WHERE gamename +=?" ); my $insert = $dbh->prepare( "INSERT INTO games (gamename, gamedesc, ga +mecounter) VALUES (?, ?, ?)" ); my $update = $dbh->prepare( "UPDATE games SET gamedesc=?, gamecount=?+ +1 where gamename=?" ); open (FILE, "<../data/games/descriptions.txt") or die $!; while (<FILE>) { chomp; ($gamename, $gamedesc) = split /\t/; if ( $select->execute($gamename) ) { $update->execute( $gamedesc, $gamecount, $gamename ); } else { $insert->execute( $gamename, $gamedesc, 0 ); } } close (FILE);
In reply to Re^3: Updating or Inserting a database from a txt file
by Nik
in thread Updating or Inserting a database from a txt file
by Nik
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |