Thread DBI-Mysql Problem (2 answers)
Opened by Mindfoo at 2009-04-07 21:06

Mindfoo
 2009-04-07 21:58
#120366 #120366
User since
2009-04-03
10 Artikel
BenutzerIn
[default_avatar]
Mit der Hilfe vom super IRC Support gelöst :D

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
sub dbwritebots {
    my $count = counter();
    my $dbh = DBI->connect( $connectionInfo, $dbuser, $dbpass )
      or die "Can.t connect to the DB: $DBI::errstr\n";
    my $getcountqry = $dbh->prepare("SELECT COUNT( * ) FROM bots WHERE id=?")
      or die $dbh->errstr();
    $getcountqry->execute($botid) or die $dbh->errstr();
    my $getcount = $getcountqry->fetchrow_arrayref();
    if($getcount->[0] == 0){
      my $sth = $dbh->prepare("INSERT INTO bots SET id=?, botqauth=?, processed=?")
        or die $dbh->errstr();
      $sth->execute($botid, $qauth, counter()) or die $dbh->errstr();
    } elsif ($getcount->[0] == 1){
      my $sth = $dbh->prepare("UPDATE bots SET botqauth=?, processed=? WHERE id=?")
        or die $dbh->errstr();
      $sth->execute($qauth, counter(), $botid) or die $dbh->errstr();
      }
}

View full thread DBI-Mysql Problem