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\Odds2wayS1;
use App\Utilities\Margin;
use PDOException;
class _2WayS1
{
@@ -27,7 +28,24 @@ class _2WayS1
$res->a2w = $odds['a2w'];
$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);
}
}
}