add PDOException on updated odds

This commit is contained in:
salam committed 2026-02-06 17:24:48 +01:00
1 parent b35c8c48e3
commit 980b716271
15 files changed
+284 -21

No files matched your search

@@ -5,6 +5,7 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Nuh;
use App\Models\Odds3way;
use App\Utilities\Margin;
use PDOException;
class _3Way
{
@@ -24,12 +25,30 @@ class _3Way
if (! $res) {
Odds3way::create($odds);
} elseif (! $block_update) {
$res->h3w = $odds['h3w'];
$res->a3w = $odds['d3w'];
$res->d3w = $odds['a3w'];
$res->flags = 1;
$res->margin = $odds['margin'];
$res->save();
$max_tries = 5;
$tries = 0;
do {
$retry = false;
try {
$res->save();
return $res;
} catch (PDOException $exc) {
if ($tries < $max_tries && $exc->errorInfo[0] == 40001 && $exc->errorInfo[1] == 1213) {
$retry = true;
sleep(1);
} else {
throw $exc;
}
}
} while ($retry);
}
}
}