AdminMailbox::create PHP Метод

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

public create ( $postData )
    public function create($postData)
    {
        if (strlen($postData["body"]) < 2) {
            throw new Exception(L::get("MESSAGE_TOO_SHORT"), 412);
        }
        if (strlen($postData["subject"]) < 3) {
            $postData["subject"] = substr($postData["body"], 0, 30);
        }
        $sth = $this->db->prepare("INSERT INTO staffmessages (sender, added, msg, subject, fromprivate) VALUES(?, NOW(), ?, ?, ?)");
        $sth->bindParam(1, $postData["sender"], PDO::PARAM_INT);
        $sth->bindParam(2, $postData["body"], PDO::PARAM_INT);
        $sth->bindParam(3, $postData["subject"], PDO::PARAM_STR);
        $sth->bindParam(4, $postData["fromprivate"], PDO::PARAM_STR);
        $sth->execute();
    }

Usage Example

Пример #1
0
     list($result, $totalCount) = $sqlerrors->query(array("limit" => $_GET["limit"], "index" => $_GET["index"]));
     httpResponse($result, $totalCount);
     break;
 case validateRoute('GET', 'cheatlogs'):
     $cheatlogs = new CheatLogs($db, $user);
     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);