Skip to content
Snippets Groups Projects
Commit 122988cf authored by Manuel Herrmann's avatar Manuel Herrmann
Browse files

count->backstepped failed

parent d8c850b5
No related branches found
No related tags found
No related merge requests found
...@@ -106,15 +106,18 @@ function index_form_to_db($data){ ...@@ -106,15 +106,18 @@ function index_form_to_db($data){
// === check regstration full === // === check regstration full ===
$res = $index_db->select("fahrten", ["regopen", "max_bachelor"], ["fahrt_id" => $config_current_fahrt_id]); $res = $index_db->select("fahrten", ["regopen", "max_bachelor"], ["fahrt_id" => $config_current_fahrt_id]);
if (!$regopen) if (!$res || $res[0]['regopen'] != "1")
return false; return false;
$index_db->exec("LOCK TABLES fahrten WRITE"); // count should not be calculated in two scripts at once $index_db->exec("LOCK TABLES fahrten WRITE"); // count should not be calculated in two scripts at once
$cnt = $index_db->count("bachelor", ["AND"=> ["backstepped" => NULL, "fahrt_id" => $config_current_fahrt_id]]);
$insertOk = $cnt < $res['max_bachelor']; $cnt = $index_db->count("bachelor", ["AND" => ["backstepped" => NULL, "fahrt_id" => $config_current_fahrt_id]]);
if ($cnt+1 >= $res['max_bachelor']) // registration is full already or after the following insert $insertOk = $cnt < $res[0]['max_bachelor'];
die("OK");
if ($cnt+1 >= $res[0]['max_bachelor']) // registration is full already or after the following insert
$index_db->update("fahrten", ["regopen" => 0], ["fahrt_id" => $config_current_fahrt_id]); $index_db->update("fahrten", ["regopen" => 0], ["fahrt_id" => $config_current_fahrt_id]);
if ($insertOk) if ($insertOk)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment