--- a/heuristics/heuristics.inc.php
+++ b/heuristics/heuristics.inc.php
@@ -8,10 +8,12 @@
//include ("valueHeuristics.php");
function runHeuristic($heuristicName, $cn)
{
+ global $conn;
// 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);
+ $query = "select count(*) from heuristic_results where heuristic_name = '$heuristicName' and \"CNID\" = '{$cn['CNID']}'";
+ $result = $conn->query($query);
+ databaseError($conn->errorInfo());
+ $r = $result->fetch(PDO::FETCH_BOTH);
if ($r[0] == 0) {
// if not, run now
$hresults = call_user_func($heuristicName, $cn);
@@ -31,9 +33,10 @@
'{$cn["supplierID"]}'
)";
// save value and cn data via sql
- $result = mysql_query($query);
- if ($result) echo "Saved $heuristicName for {$cn["CNID"]}
\n";
- elseif (strpos(mysql_error() , "Duplicate entry") === false) echo $hresults . " failed insert.
" . mysql_error() . "
$query
\n";
+ $result = $conn->query($query);
+ $errors = $conn->errorInfo();
+ if ($errors[2] == "") echo "Saved $heuristicName for {$cn["CNID"]}
\n";
+ elseif (strpos($errors[2] , "Duplicate entry") === false) echo $hresults . " failed insert.
" . print_r($errors,true) . "
$query
\n";
}
}
?>