7 Einträge, 1 Seite |
&UpdateFromHash($dbh,{'field' => 'new_value','nextfield'=>'new_value'},'tabelle',["field LIKE '%irgendwas%'","field2 = 'value'"],$limit);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
sub UpdateFromHash {
my $DBH = $_[0] or &FatalError('DBx0001');
my %Fields = %{$_[1]} or &FatalError('DBx0006',['Fields']);
my $Table = $_[2] or &FatalError('DBx0006',['Table']);
my @Conds = @{$_[3]} or &FatalError('DBx0006',['Conditions']);
my $Limit = $_[4];
my $Statement;
$Statement = 'UPDATE '.$Table.' SET '.join (', ',&{sub{my @f;push @f, "$_ = ".$DBH->quote($Fields{$_}) for (keys(%Fields));return @f;}}).
' WHERE '.join (' AND ',@Conds).($Limit?" LIMIT $Limit":"").';';
if ($DBH->do($Statement)) {
return 1;
}
else {
&FatalError('DBx0007', [$Statement, $DBH->errstr()]);
}
}
&UpdateFromHash($CFG{'DBH'},{ 'falselogins' => 'falselogins+1' }, 'users', ["name = '$Username'"],1);
7 Einträge, 1 Seite |