false, 'ERROR' => 'missing_UserID']); if ($businessID === 0) apiAbort(['OK' => false, 'ERROR' => 'missing_BusinessID']); $params = [$userID, $businessID]; $spVal = $servicePointID > 0 ? '?' : 'NULL'; if ($servicePointID > 0) $params[] = $servicePointID; queryTimed(" INSERT INTO UserPresence (UserID, BusinessID, ServicePointID, LastSeenOn) VALUES (?, ?, $spVal, NOW()) ON DUPLICATE KEY UPDATE BusinessID = VALUES(BusinessID), ServicePointID = VALUES(ServicePointID), LastSeenOn = NOW() ", $params); jsonResponse(['OK' => true]); } catch (Exception $e) { jsonResponse(['OK' => false, 'ERROR' => 'server_error', 'MESSAGE' => $e->getMessage()]); }