spewn
Programmer
- May 7, 2001
- 1,034
here's the code:
The idea being that on the first pass, the passed variable would be clean, but on the second pass it would match.
This works, but not fully, as it doesn't catch all dupes and I haven't figured out the pattern of error to figure it out.
Anyway, I think it might be the way i'm getting the $passedvariable, as this:
works exactly to show me the dupes in my_table, but doesn't match a couple that are exactly the same to me, visually.
i'm pulling the information from a text file, where each entry is on its own line, and it goes line by line. I thought that it might by a newline issue, so I chomped the line variable before matching/saving in DB.
this is a more complete code example:
any help would be appreciated. like i said, even the SQL matcher wasn't recognizing two entries that are visually the same to me.
thanks!
- g
Code:
$passedvariable='whatevernextinloop';
$sth = $dbh->prepare("SELECT uniqueid FROM my_table WHERE infofield1 = '$passedvariable'");
$sth->execute;
$count = $sth->rows;
if ($count > 0) {$dupeleadcount++;$dispo='dupe';}
else {$loadtotalcount++;$dispo='';}
The idea being that on the first pass, the passed variable would be clean, but on the second pass it would match.
This works, but not fully, as it doesn't catch all dupes and I haven't figured out the pattern of error to figure it out.
Anyway, I think it might be the way i'm getting the $passedvariable, as this:
Code:
$sth = $dbh->prepare("SELECT infofield1, COUNT(infofield1) FROM my_table GROUP BY infofield1 HAVING ( COUNT(infofield1) > 1 )");
$sth->execute;
works exactly to show me the dupes in my_table, but doesn't match a couple that are exactly the same to me, visually.
i'm pulling the information from a text file, where each entry is on its own line, and it goes line by line. I thought that it might by a newline issue, so I chomped the line variable before matching/saving in DB.
this is a more complete code example:
Code:
open (ULFNAME, $myfilelocation);
binmode ULFNAME;
@lines = <ULFNAME>;
@lines = sort(@lines);
foreach $line (@lines) {
chomp($line);
if ($line ne '') {
$sth = $dbh->prepare("SELECT uniqueid FROM my_table WHERE infofield1 = '$line'");
$sth->execute;
$count = $sth->rows;
if ($count > 0) {$dupecount++;$dispo='dupe';}
else {$dispo='unique';}
$sth2 = $dbh->prepare("insert into my_table values ('0','$dispo','$line')");
$sth2->execute;
}
}
any help would be appreciated. like i said, even the SQL matcher wasn't recognizing two entries that are visually the same to me.
thanks!
- g