More MySQL purging
[contractdashboard.git] / heuristics / heuristics.inc.php
blob:a/heuristics/heuristics.inc.php -> blob:b/heuristics/heuristics.inc.php
--- a/heuristics/heuristics.inc.php
+++ b/heuristics/heuristics.inc.php
@@ -10,8 +10,8 @@
 {
 	// check  if already ran
 	$query = "select count(*) from heuristic_results where heuristic_name = '$heuristicName' and CNID = '{$cn['CNID']}'";
-	$result = mysql_query($query);
-	$r = mysql_fetch_array($result);
+	    $result = $conn->query($query);
+    $r = $result->fetch(PDO::FETCH_BOTH);
 	if ($r[0] == 0) {
 		// if not, run now
 		$hresults = call_user_func($heuristicName, $cn);
@@ -31,9 +31,10 @@
            '{$cn["supplierID"]}'
     )";
 		// save value and cn data via sql
-		$result = mysql_query($query);
-		if ($result) echo "Saved $heuristicName for {$cn["CNID"]} <br>\n";
-		elseif (strpos(mysql_error() , "Duplicate entry") === false) echo $hresults . " failed insert.<br>" . mysql_error() . " <br>  $query <br><br>\n";
+		$result = $conn->query($query);
+                $errors = $conn->errorInfo();
+		if ($errors[2] == "") echo "Saved $heuristicName for {$cn["CNID"]} <br>\n";
+		elseif (strpos($errors[2] , "Duplicate entry") === false) echo $hresults . " failed insert.<br>" . print_r($errors,true) . " <br>  $query <br><br>\n";
 	}
 }
 ?>