diff --git a/backend-php/api.php b/backend-php/api.php index fa27072..0e282bb 100644 --- a/backend-php/api.php +++ b/backend-php/api.php @@ -210,7 +210,7 @@ CreateApi(function ($api) { // return only changes $content = json_decode($results[0]['content'], true); $has_full_rings = true; - foreach ($content as $idx => $item) { + foreach ($content as $_idx => $item) { if (!isset($item['t-begin']) || !isset($item['t-end'])) { $has_full_rings = false; // optionally record $idx @@ -225,7 +225,10 @@ CreateApi(function ($api) { // without rings $results = FastDBReq($db, "SELECT * FROM RINGS WHERE classId = ?", [$classId]); $rings = json_decode(findClosestDateSort($results, $day)['content'], true); - $out = joinArraysByKey($content, $rings, true); + $out = $content; + if ($rings !== null) { + $out = joinArraysByKey($content, $rings, true); + } $db = null; return ['data' => $out, 'type' => 1]; } @@ -238,7 +241,10 @@ CreateApi(function ($api) { $schedule = json_decode(findClosestDateSort($results, $day)['content'], true); $results = FastDBReq($db, "SELECT * FROM RINGS WHERE classId = ?", [$classId]); $rings = json_decode(findClosestDateSort($results, $day)['content'], true); - $out = joinArraysByKey($schedule, $rings); + $out = $schedule; + if ($rings !== null) { + $out = joinArraysByKey($schedule, $rings); + } $db = null; return ['data' => $out, 'type' => 0]; } else {