當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ArticleModel::exists方法代碼示例

本文整理匯總了PHP中ArticleModel::exists方法的典型用法代碼示例。如果您正苦於以下問題:PHP ArticleModel::exists方法的具體用法?PHP ArticleModel::exists怎麽用?PHP ArticleModel::exists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ArticleModel的用法示例。


在下文中一共展示了ArticleModel::exists方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: indexAction

 public function indexAction()
 {
     header('content-type: application/json');
     header('Access-Control-Allow-Origin: *');
     header('Access-Control-Allow-Methods: POST');
     $valid = true;
     $errors = [];
     if (ArticleModel::exists($this->pdo, htmlentities($_POST['id']))) {
         $id = htmlentities($_POST['id']);
     } else {
         return json_encode($errors['id'] = '<span class="errors">Cet article n\'existe pas</span>');
     }
     $title = trim(ucfirst(strtolower(htmlentities($_POST['title']))));
     $content = trim(htmlentities($_POST['content']));
     if (!isset($title) || empty($title)) {
         $errors['title'] = '<span class="errors">Non saisi</span>';
         $valid = false;
     } elseif (strlen($title) > 51) {
         $errors['title'] = '<span class="errors">Trop long</span>';
         $valid = false;
     }
     if (!isset($content) || empty($content)) {
         $errors['content'] = '<span class="errors">Non saisi</span>';
         $valid = false;
     }
     $errors['valid'] = $valid;
     if ($valid) {
         $errors['edit'] = ArticleModel::edit($this->pdo, $id, $title, $content, $_SESSION['auth']['username']);
     }
     echo json_encode($errors);
 }
開發者ID:Alegzandr,項目名稱:alexandre.farrenq.dev2018-my_blog,代碼行數:31,代碼來源:EditArticleController.php

示例2: indexAction

 public function indexAction()
 {
     header('content-type: application/json');
     header('Access-Control-Allow-Origin: *');
     header('Access-Control-Allow-Methods: POST');
     $valid = true;
     $errors = [];
     $id = htmlentities($_POST['article']);
     $user = $_SESSION['auth']['username'];
     $comment = trim(htmlentities($_POST['comment']));
     $timestamp = time();
     if (!ArticleModel::exists($this->pdo, $id)) {
         $errors['article'] = '<span class="errors">Cet article n\'existe pas</span>';
         $valid = false;
     } elseif (!isset($comment) || empty($comment)) {
         $errors['comment'] = '<span class="errors">Non saisi</span>';
         $valid = false;
     } elseif (strlen($comment) > 200) {
         $errors['comment'] = '<span class="errors">200 caractères max</span>';
         $valid = false;
     }
     $errors['valid'] = $valid;
     if ($valid) {
         CommentModel::create($this->pdo, $id, $user, $comment, $timestamp);
     }
     echo json_encode($errors);
 }
開發者ID:Alegzandr,項目名稱:alexandre.farrenq.dev2018-my_blog,代碼行數:27,代碼來源:CommentController.php

示例3: indexAction

 public function indexAction()
 {
     if (empty(explode('/', $_SERVER['REQUEST_URI'], 4)[2])) {
         header('Location : /');
         exit;
     } else {
         $article_id = explode('/', $_SERVER['REQUEST_URI'], 4)[2];
     }
     if (ArticleModel::exists($this->pdo, $article_id)) {
         include '../app/views/article.php';
         return;
     }
 }
開發者ID:Alegzandr,項目名稱:alexandre.farrenq.dev2018-my_blog,代碼行數:13,代碼來源:ArticleController.php

示例4: indexAction

 public function indexAction()
 {
     if (empty(explode('/', $_SERVER['REQUEST_URI'], 4)[2])) {
         header('Location: /');
         exit;
     } else {
         $article_id = explode('/', $_SERVER['REQUEST_URI'], 4)[2];
     }
     if (ArticleModel::exists($this->pdo, $article_id)) {
         if ($_SESSION['auth']['username'] === ArticleModel::getAuthor($this->pdo, $article_id) || $_SESSION['auth']['permissions'] === 'superadmin') {
             include '../app/views/editarticle.php';
             return;
         }
     } else {
         header('Location: /404');
         exit;
     }
 }
開發者ID:Alegzandr,項目名稱:alexandre.farrenq.dev2018-my_blog,代碼行數:18,代碼來源:EditController.php


注:本文中的ArticleModel::exists方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。