AdminMailbox::update PHP Метод

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

public update ( $id, $postData )
    public function update($id, $postData)
    {
        if ($this->user->getClass() < User::CLASS_ADMIN) {
            throw new Exception(L::get("PERMISSION_DENIED"), 401);
        }
        $message = $this->get($id);
        if ($message["answeredby"] != 0 && $message["answeredby"] != $this->user->getId()) {
            throw new Exception(L::get("MESSAGE_ALREADY_PROCESSING"), 401);
        }
        $sth = $this->db->prepare('UPDATE staffmessages SET answered = ?, answeredby = ?, answer = ?, svaradwhen = ? WHERE id = ?');
        $sth->bindParam(1, $postData["answered"], PDO::PARAM_INT);
        $sth->bindParam(2, $postData["answeredBy"]["id"], PDO::PARAM_INT);
        $sth->bindParam(3, $postData["answer"], PDO::PARAM_STR);
        $sth->bindParam(4, $postData["answeredAt"], PDO::PARAM_STR);
        $sth->bindParam(5, $id, PDO::PARAM_INT);
        $sth->execute();
    }

Usage Example

Пример #1
0
     list($result, $totalCount) = $cheatlogs->query(array("limit" => $_GET["limit"], "index" => $_GET["index"], "userid" => $_GET["userid"]));
     httpResponse($result, $totalCount);
     break;
 case validateRoute('GET', 'admin-mailbox'):
     $adminMailbox = new AdminMailbox($db, $user);
     list($result, $totalCount) = $adminMailbox->query(array("limit" => $_GET["limit"], "index" => $_GET["index"]));
     httpResponse($result, $totalCount);
     break;
 case validateRoute('POST', 'admin-mailbox'):
     $adminMailbox = new AdminMailbox($db, $user);
     $adminMailbox->create($postdata);
     httpResponse();
     break;
 case validateRoute('PATCH', 'admin-mailbox/\\d+'):
     $adminMailbox = new AdminMailbox($db, $user);
     $adminMailbox->update((int) $params[1], $postdata);
     httpResponse();
     break;
 case validateRoute('GET', 'comments'):
     $comments = new Comments($db, $user, $torrent);
     list($result, $totalCount) = $comments->getAllComments((int) $_GET["limit"] ?: 10, (int) $_GET["index"] ?: 0);
     httpResponse($result, $totalCount);
     break;
 case validateRoute('GET', 'search'):
     $sqlerrors = new SqlErrors($db, $user);
     list($result, $totalCount) = $user->search($_GET);
     httpResponse($result, $totalCount);
     break;
 case validateRoute('POST', 'reseed-requests'):
     $logs = new Logs($db, $user);
     $mailbox = new Mailbox($db, $user);