--- a/heuristics/heuristics.inc.php
+++ b/heuristics/heuristics.inc.php
@@ -1,33 +1,47 @@
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);
+ if (!isset($hresults["heuristic_value"]) || !isset($hresults["raw_value"]) || !isset($hresults["mean"]) || !isset($hresults["stddev"])) {
+ print_r($hresults);
+ die("Missing field in heurtistic $heuristicName result");
+ }
+ $query = "insert into heuristic_results values('$heuristicName',
'{$hresults["heuristic_value"]}',
'{$hresults["raw_value"]}',
'{$hresults["mean"]}',
'{$hresults["stddev"]}',
'{$cn["CNID"]}',
NOW(),
- '{$cn["publishDate"]}',
- '{$cn["agencyABN"]}',
- '{$cn["supplierID"]}'
+ '{$cn["publishDate"]}',"
+ //."'{$cn["agencyABN"]}',
+ ."0,'{$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";
+ // save value and cn data via sql
+ $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";
+ }
}
+
?>
+