Skip to content

Commit

Permalink
changed json to be 'result':[{}]
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrikBuetler committed Aug 14, 2024
1 parent 55e5498 commit cb2f6c9
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions libraries/dba/AbstractModelFactory.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -819,14 +819,6 @@ public function incrementJobCountAtomically($jobId, $resultCollection)
$checker->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR);
$checker->execute();

$checker2 = $dbh->prepare("SELECT * FROM Job WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;");
$checker2->bindParam(':jobId', $jobId, PDO::PARAM_INT);
$checker2->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR);
$checker2->execute();
$fetch2 = $checker2->fetch(PDO::FETCH_ASSOC);
file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', print_r($fetch2, true)."\n", FILE_APPEND);


$stmt2 = $dbh->prepare("UPDATE Job
SET logalyzerResults = JSON_SET(
logalyzerResults,
Expand All @@ -836,20 +828,27 @@ public function incrementJobCountAtomically($jobId, $resultCollection)
JSON_EXTRACT(logalyzerResults, JSON_QUOTE(:index))
) AS UNSIGNED) + :amount AS CHAR))
WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;");
#if ($stmt2 !== false) {
#file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nExecuting Query 2: " . var_export($stmt2->queryString, true) . "\n", FILE_APPEND);
#file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "With Parameters: index=" . $index['@index'] . ", amount=" . $pattern['count'] . ", jobId=" . $jobId . ", pattern=" . $pattern['pattern'] . "\n", FILE_APPEND);
# } else {
#file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in prepare() for Query 2\n", FILE_APPEND);
# }
#$stmt2->bindParam(':index', $index['@index'], PDO::PARAM_STR);
#$stmt2->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR);
#$stmt2->bindParam(':amount', $pattern['count'], PDO::PARAM_INT);
#$stmt2->bindParam(':jobId', $jobId, PDO::PARAM_INT);
#if (!$stmt2->execute()) {
# file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in execute()\n", FILE_APPEND);
#}
#Factory::getJobFactory()->update(Factory::getJobFactory()->get($jobId));
if ($stmt2 !== false) {
file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nExecuting Query 2: " . var_export($stmt2->queryString, true) . "\n", FILE_APPEND);
file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "With Parameters: index=" . $index['@index'] . ", amount=" . $pattern['count'] . ", jobId=" . $jobId . ", pattern=" . $pattern['pattern'] . "\n", FILE_APPEND);
} else {
file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in prepare() for Query 2\n", FILE_APPEND);
}
$stmt2->bindParam(':index', $index['@index'], PDO::PARAM_STR);
$stmt2->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR);
$stmt2->bindParam(':amount', $pattern['count'], PDO::PARAM_INT);
$stmt2->bindParam(':jobId', $jobId, PDO::PARAM_INT);
if (!$stmt2->execute()) {
file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', "\nError in execute()\n", FILE_APPEND);
}

$checker2 = $dbh->prepare("SELECT * FROM Job WHERE jobId = :jobId AND JSON_SEARCH(logalyzerResults, 'one', :pattern) is not null;");
$checker2->bindParam(':jobId', $jobId, PDO::PARAM_INT);
$checker2->bindParam(':pattern', $pattern['pattern'], PDO::PARAM_STR);
$checker2->execute();
$fetch2 = $checker2->fetch(PDO::FETCH_ASSOC);
file_put_contents(UPLOADED_DATA_PATH . 'log/' . $jobId . '.log', print_r($fetch2, true)."\n", FILE_APPEND);

}
}
catch (PDOException $e) {
Expand Down

0 comments on commit cb2f6c9

Please sign in to comment.