Example #1
0
 public static function deleteVideo($id)
 {
     //id must be an integer
     $orig_id = $id;
     $id = MyUtil::parseInt($id);
     if ($id == null) {
         return MyUtil::fnOk(false, "Must be a valid id: {$orig_id}", null);
     }
     $stm = "DELETE FROM " . self::$table_name . " WHERE id = {$id}";
     $result = ConnDB::query_db($stm);
     if (!$result) {
         return MyUtil::fnOk(false, "SQL Error", null);
     }
     return MyUtil::fnOk(true, "Deleted Video", $result);
 }
Example #2
0
                     }
                 } else {
                     JsonResponse::sendResponse(400, $fnHash3['reason'] . '3');
                 }
             } else {
                 JsonResponse::sendResponse(400, $fnHash2['reason'] . '2');
             }
         } else {
             JsonResponse::sendResponse(400, $fnHash['reason']);
         }
     } else {
         JsonResponse::sendResponse(404, "Invalid Spire API Request");
     }
 } elseif (isset($_GET['winningVideoBySession'])) {
     if ($_SERVER['REQUEST_METHOD'] === "GET") {
         $session_id = MyUtil::parseInt($_GET['winningVideoBySession']);
         if ($session_id != null) {
             $fnOk = SessionDAO::getWinningVideoId($session_id);
             if ($fnOk['ok']) {
                 $logger->writeLog("Getting winning vid for session: {$session_id}/" . $_GET['winningVideoBySession']);
                 JsonResponse::sendResponse(200, $fnOk['result']);
             } else {
                 $logger->writeLog("Failed Getting winning vid for session: {$session_id}/" . $_GET['winningVideoBySession']);
                 JsonResponse::sendResponse(400, $fnOk['reason']);
             }
         } else {
             JsonResponse::sendResponse(400, "Invalid session_id syntax. must be int: " . $_GET['winningVideoBySession']);
         }
     } else {
         JsonResponse::sendResponse(404, "Invalid Spire API Request");
     }
Example #3
0
 public static function getArtistFromUser($orig_id)
 {
     //id must be an integer
     $id = MyUtil::parseInt($orig_id);
     if (!$id) {
         return MyUtil::fnOk(false, "Must be a valid id: {$orig_id}", null);
     }
     $stm = " SELECT art.* " . " FROM spire.user_to_artist ua " . "    JOIN spire.artists art ON ua.artist_id = art.id " . " WHERE ua.user_id = {$id} ";
     $result = ConnDB::query_db($stm);
     if (!$result) {
         return MyUtil::fnOk(false, "SQL Error", null);
     }
     $retArray = [];
     while ($row = pg_fetch_assoc($result)) {
         array_push($retArray, $row);
     }
     return MyUtil::fnOk(true, "Found Artist Id", $retArray);
 }
Example #4
0
 public static function getArtistIdFromUser($id)
 {
     //id must be an integer
     $id = MyUtil::parseInt($id);
     if (!$id) {
         return MyUtil::fnOk(false, "Must be a valid id: {$id}", null);
     }
     $stm = "SELECT artist_id from spire.user_to_artist where user_id = {$id} ";
     $result = ConnDB::query_db($stm);
     if (!$result) {
         return MyUtil::fnOk(false, "SQL Error", null);
     }
     return MyUtil::fnOk(true, "Found Artist Id", $result['artist_id']);
 }
Example #5
-1
 public static function deleteVote($session_id, $user_id)
 {
     //id must be an integer
     $orig_sess_id = $session_id;
     $orig_user_id = $user_id;
     //get parsed integers
     $session_id = MyUtil::parseInt($session_id);
     $user_id = MyUtil::parseInt($user_id);
     //check
     if ($session_id == null || $user_id == null) {
         return MyUtil::fnOk(false, "Must be valid ids - session:{$orig_sess_id}, user:{$orig_user_id}", null);
     }
     $stm = "DELETE FROM " . self::$table_name . " WHERE session_id = {$session_id} AND user_id = {$user_id}";
     $result = ConnDB::query_db($stm);
     if (!$result) {
         return MyUtil::fnOk(false, pg_error(), null);
     }
     return MyUtil::fnOk(true, "", $result);
 }