Leser: 1
|< 1 2 3 >| | 22 Einträge, 3 Seiten |
1
2
3
4
5
6
7
8
9
10
11
12
ID status Text MD5
1 2329 "text1 d41d8cd98f00b
2 2329 " text2 da5766dggfhd8
3 1423 "text3 yfgbdf232424fgf
Tabelle Daten:
ID Status Datum RfID
1 2911 2006-03-19 1
2 2907 2004-07-23 2
3 2923 2006-08-11 3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/perl -w
use strict;
use warnings;
use DBI;
use Digest::MD5;
my $dbh;
my $raw_data;
my $sqldata;
open(DAT, '<','../gate_common/MySQLAccount.txt') or die"Could not open SQL-Data-file!";
$raw_data=<DAT>;
close(DAT);
chomp $raw_data;
my ($host,$user,$pass,$db) = split(/:/, $raw_data);
print "host ".$host."\n"."user ".$user."\n"."pass ".$pass."\n"."db ".$db."\n";
$dbh = DBI->connect("DBI:mysql:".$db.":".$host,$user,$pass) or die "Connect Error: $DBI::errstr()\n";
Query($dbh);
rechnen($dbh);
sub Query{
my $query;
my $sth;
my $execu;
my $newdata;
my $file;
my $ds;
my @ergebnisse;
my @row;
$query = "SELECT RefID FROM ´Rechnen ,Daten WHERE Rechnen .ID=DatenRefID ORDER BY TS_LastChange ";
$sth = $dbh->prepare($query) or die "$DBI::errstr\n";
$sth->execute or die "$DBI::errstr\n";
while($newdata = $sth->fetchrow_array()){
if(not defined $newdata){
$dbh->do("INSERT INTO Rechnen(ID) VALUES(?)",undef) or die $dbh->errstr();
}
print"$newdata\n";
}
$sth->finish();
}
Quote*) Du machst ein fetchrow_array, speicherst das Ergebnis aber in einem Skalar. Da bekommst Du die Anzahl der Elemente raus! soll ich dann folgendes schreiben :
while($newdata = $sth->fetchrow_hashref())
SELECT MD5(Text) FROM Rechnen WHERE ID=1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/perl -w
use strict;
use warnings;
use DBI;
use Digest::MD5;
my $dbh;
my $raw_data;
my $sqldata;
open(DAT, '<','../gate_common/MySQLAccount.txt') or die"Could not open SQL-Data-file!";
$raw_data=<DAT>;
close(DAT);
chomp $raw_data;
my ($host,$user,$pass,$db) = split(/:/, $raw_data);
print "host ".$host."\n"."user ".$user."\n"."pass ".$pass."\n"."db ".$db."\n";
$dbh = DBI->connect("DBI:mysql:".$db.":".$host,$user,$pass) or die "Connect Error: $DBI::errstr()\n";
Query($dbh);
sub Query{
my $query;
my $sth;
my $execu;
my $newdata;
my $file;
my $ds;
my @ergebnisse;
my @row;
$query = "SELECT RefID FROM ´Rechnen ,Daten WHERE Rechnen .ID=DatenRefID ORDER BY TS_LastChange ";
$sth = $dbh->prepare($query) or die "$DBI::errstr\n";
$sth->execute or die "$DBI::errstr\n";
while($newdata = $sth->fetchrow_array()){
if(not defined $newdata){
$dbh->do("INSERT INTO Rechnen(ID) VALUES(?)",undef) or die $dbh->errstr();
}
print"$newdata\n";
}
$sth->finish();
}
SELECT * FROM Rechnen FULL JOIN Daten ON (Rechnen.ID = Daten.RfID);
1
2
3
4
5
6
7
8
id | status | data | md5sum | id | status | datum | rf_id
----+--------+-------+----------------------------------+----+--------+------------+------
-
1 | 2329 | text1 | cef7ccd89dacf1ced6f5ec91d759953f | 1 | 2911 | 2006-03-19 | 1
2 | 2329 | text2 | fe6123a759017e4a2af4a2d19961ed71 | 2 | 2907 | 2004-07-23 | 2
3 | 1423 | text3 | 265246eadd25390e2406a0d9bd22242b | 3 | 2923 | 2006-08-11 | 3
| | | | 4 | 12234 | 2006-12-17 | 4
5 | 1234 | text5 | 48fa2467e5e644c8a594757d255db7eb | | | |
UPDATE Rechnen SET md5sum=MD5('neuer Wert fuer Pruefsumme') WHERE ID=2
|< 1 2 3 >| | 22 Einträge, 3 Seiten |