Reports::create PHP Метод

create() публичный Метод

public create ( $postdata )
    public function create($postdata)
    {
        if (!preg_match("/^(torrent|post|pm|request|comment|subtitle|user)\$/", $postdata["type"])) {
            throw new Exception(L::get("REPORT_WRONG_TYPE"), 400);
        }
        if (strlen($postdata["reason"]) < 2) {
            throw new Exception(L::get("REPORT_REASON_TOO_SHORT"), 400);
        }
        $sth = $this->db->prepare('INSERT INTO reports (added, userid, reason, targetid, type) VALUES (NOW(), ?, ?, ?, ?)');
        $sth->bindValue(1, $this->user->getId(), PDO::PARAM_INT);
        $sth->bindParam(2, $postdata["reason"], PDO::PARAM_STR);
        $sth->bindParam(3, $postdata["targetid"], PDO::PARAM_STR);
        $sth->bindParam(4, $postdata["type"], PDO::PARAM_INT);
        $sth->execute();
    }

Usage Example

Пример #1
0
     $loginAttempts = new LoginAttempts($db, $user);
     httpResponse($loginAttempts->delete((int) $params[1]));
     break;
 case validateRoute('GET', 'signups'):
     $signups = new Signups($db, $user);
     list($result, $totalCount) = $signups->query((int) $_GET["limit"], (int) $_GET["index"]);
     httpResponse($result, $totalCount);
     break;
 case validateRoute('GET', 'ipchanges'):
     $ipchanges = new IpChanges($db, $user);
     list($result, $totalCount) = $ipchanges->query((int) $_GET["limit"], (int) $_GET["index"]);
     httpResponse($result, $totalCount);
     break;
 case validateRoute('POST', 'reports'):
     $reports = new Reports($db, $user);
     httpResponse($reports->create($postdata));
     break;
 case validateRoute('GET', 'reports'):
     $mailbox = new Mailbox($db, $user);
     $torrent = new Torrent($db, $user);
     $subtitles = new Subtitles($db, $user);
     $requests = new Requests($db, $user);
     $forum = new Forum($db, $user);
     $log = new Logs($db);
     $comments = new Comments($db, $user);
     $reports = new Reports($db, $user, $torrent, $subtitles, $requests, $forum, $mailbox, $comments, $log);
     list($result, $totalCount) = $reports->query(array("limit" => $_GET["limit"], "index" => $_GET["index"]));
     httpResponse($result, $totalCount);
     break;
 case validateRoute('PATCH', 'reports/\\d+'):
     $reports = new Reports($db, $user);
All Usage Examples Of Reports::create