Thread MySQL Problem: geht nicht (3 answers)
Opened by Gast at 2004-01-30 13:10

renee
 2004-01-30 14:06
#79659 #79659
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use DBI;
my $user = 'username';
my $password = 'password';
my $database = 'mydb';
my $host = 'localhost';
my @entries = ();

my $dbh = DBI->connect("DBI:mysql:$database:$host",$username,$password) or die $DBI::errstr;
my $sth = $dbh->prepare("SELECT * FROM table;");
$sth->execute();
while(my @array = $sth->fetchrow_array){
if($array[0] =~ /SUCHTEIL/){
$array[0] =~ s~SUCHTEIL~ERSETZUNGSTEIL~OPTIONEN;
push(@entries,\@array);
}
}
$sth->finish();

foreach(@entries){
$dbh->do("UPDATE table SET spalte1 = '$array[0]', spalte2 = '$array[1]'... WHERE ID = id;");
}

$dbh->disconnect();

ungetestet
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/

View full thread MySQL Problem: geht nicht