in reply to Re^7: Inserting, update and deleteting a database under conditions
in thread Inserting, update and deleteting a database under conditions
The content of @dbfiles isnt what i think it is though. What i wanted to return is all table's articles contents.#===================================================================== +========== my $db = ( $ENV{'SERVER_NAME'} !~ /varsa/ ) ? DBI->connect('DBI:mysql:orthodox;localhost', 'root', '******' +, {RaiseError=>1}) : DBI->connect('DBI:mysql:skieros_orthodox;www.freegreece.net', + 'skieros_root', '******', {RaiseError=>1}); #===================================================================== +========== my @files = glob "$ENV{'DOCUMENT_ROOT'}/data/text/*.txt"; my @filenames = map {/([^\/]+)\.txt$/} @files; my @dbfiles = $db->do( 'SELECT title, body FROM articles' ); foreach my $filename (@filenames) { unless( grep /^\Q$filename\E$/, @dbfiles ) { open FILE, "<$filename" or die "Cannot open $filename: $!"; my $data = <FILE>; close FILE; unless( grep /^\Q$data\E$/, @dbfiles ) { $db->do('INSERT INTO test (title, body) VALUES (?, ?)', undef +, $filename, $data) } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^9: Inserting, update and deleteting a database under conditions
by Anonymous Monk on Jan 15, 2008 at 22:30 UTC | |
by Nik (Initiate) on Jan 16, 2008 at 10:28 UTC |