Watching::query PHP Method

query() public method

public query ( $userId, $imdbId = null )
    public function query($userId, $imdbId = null)
    {
        if ($userId != $this->user->getId() && $this->getClass() < self::CLASS_ADMIN) {
            throw new Exception(L::get("PERMISSION_DENIED"), 401);
        }
        if ($imdbId) {
            $sth = $this->db->query("SELECT bevaka.*, imdbinfo.imdbid, imdbinfo.title, imdbinfo.year, imdbinfo.imdbid AS imdbid2 FROM bevaka JOIN imdbinfo ON bevaka.imdbid = imdbinfo.id WHERE bevaka.userid = " . $userId . " AND bevaka.imdbid = " . $imdbId);
        } else {
            $sth = $this->db->query("SELECT bevaka.*, imdbinfo.imdbid, imdbinfo.title, imdbinfo.year, imdbinfo.imdbid AS imdbid2 FROM bevaka JOIN imdbinfo ON bevaka.imdbid = imdbinfo.id WHERE bevaka.userid = " . $userId . " ORDER BY imdbinfo.title ASC");
        }
        $fixed = array();
        while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
            $row["swesub"] = $row["swesub"] == 1;
            if ($row["typ"] == 0) {
                $formatsArray = explode(",", $row["format"]);
                $row["formats"] = array("hd720" => array_search("4", $formatsArray) > -1, "hd1080" => array_search("5", $formatsArray) > -1, "dvdrpal" => array_search("1", $formatsArray) > -1, "dvdrcustom" => array_search("2", $formatsArray) > -1, "bluray" => array_search("13", $formatsArray) > -1);
            } else {
                $row["formats"] = array("hd720" => strpos($row["format"], "6") > -1, "hd1080" => strpos($row["format"], "7") > -1, "dvdrpal" => strpos($row["format"], "3") > -1, "dvdrcustom" => strpos($row["format"], "2") > -1);
            }
            array_push($fixed, $row);
        }
        return $fixed;
    }

Usage Example

Example #1
0
     httpResponse($invitees);
     break;
 case validateRoute('GET', 'users/\\d+/bonuslog'):
     $bonuslog = $user->getBonusLog($params[1] ?: 0, (int) $_GET["limit"] ?: 10);
     httpResponse($bonuslog);
     break;
 case validateRoute('GET', 'users/\\d+/iplog'):
     $iplog = $user->getIpLog($params[1] ?: 0, (int) $_GET["limit"] ?: 10);
     httpResponse($iplog);
     break;
 case validateRoute('GET', 'users/\\d+/snatchlog'):
     httpResponse($user->getSnatchLog((int) $params[1]));
     break;
 case validateRoute('GET', 'users/\\d+/watching'):
     $watching = new Watching($db, $user);
     httpResponse($watching->query($params[1], (int) $_GET["imdbid"]));
     break;
 case validateRoute('POST', 'users/\\d+/watching'):
     $watching = new Watching($db, $user);
     httpResponse($watching->create($params[1], $postdata));
     break;
 case validateRoute('PATCH', 'users/\\d+/watching/\\d+'):
     $watching = new Watching($db, $user);
     httpResponse($watching->update($params[1], $params[3], $postdata));
     break;
 case validateRoute('DELETE', 'users/\\d+/watching/\\d+'):
     $watching = new Watching($db, $user);
     httpResponse($watching->delete($params[1], $params[3]));
     break;
 case validateRoute('GET', 'users/\\d+/watching/toplist'):
     $watching = new Watching($db, $user);
All Usage Examples Of Watching::query