Forum Moderators: open
my $sth_data_new = $dbh->prepare("INSERT IGNORE INTO pm_data (hash, message) VALUES (MD5(?), ?)");
$sth_data_new->execute($comment, $comment);
my $sth_select_data_new = $dbh->prepare("SELECT refid FROM pm_data WHERE hash = MD5(?) LIMIT 1");
$sth_select_data_new->execute($comment);
$refid = $sth->fetchrow_array(); my $sth_data = $dbh->prepare("INSERT IGNORE INTO pm_data (hash, message) VALUES (MD5(?), ?)");
# if inserted, $num_rows = 1; else it will = 0 or -1
$num_rows = $sth_data->execute($contents{'comment'}, $contents{'comment'});
if ($num_rows == 1) {
# should I be using $dbh->last_insert_id() instead?
$refid = $dbh->{'mysql_insertid'};
}
else {
my $sth_select_new = $dbh->prepare("SELECT refid FROM pm_data WHERE hash = MD5(?) LIMIT 1");
$sth_select_new->execute($comment);
$refid = $sth->fetchrow_array();
}