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


PHP News::insert方法代碼示例

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


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

示例1: actionAdd

 public function actionAdd()
 {
     if (!isset($_POST['NewsHeader']) || !isset($_POST['NewsPreview']) || !isset($_POST['NewsText']) || !isset($_POST['NewsTags'])) {
         header("HTTP/1.0 404 Not Found");
         throw new E404Exception('Required params can not be null');
     }
     $NewsRecord = new News();
     $NewsRecord->NewsHeader = $_POST['NewsHeader'];
     $NewsRecord->NewsPreview = $_POST['NewsPreview'];
     $NewsRecord->NewsText = $_POST['NewsText'];
     $NewsRecord->NewsTags = $_POST['NewsTags'];
     $NewsRecord->publishdate = 'NOW()';
     $NewsRecord->insert();
     $mail = new \PHPMailer();
     $mail->isSMTP();
     $mail->Host = 'smtp.gmail.com';
     $mail->Username = 'shilov.kirill.transas@gmail.com';
     $mail->Password = 'qwertyASDFGHzxcvbn';
     $mail->SMTPAuth = true;
     $mail->SMTPSecure = 'ssl';
     $mail->Port = '465';
     $mail->addAddress('shilov.kirill.transas@gmail.com');
     $mail->Body = 'Created news';
     $mail->AltBody = 'Body created';
     $mail->send();
     $mail->clearAddresses();
     header('Location: ./index.php');
 }
開發者ID:Alexandr1987,項目名稱:barricade,代碼行數:28,代碼來源:NewsAdminController.php

示例2: actionInsert

 public function actionInsert()
 {
     $view = new View();
     $view->display('insert.php');
     $article = new News();
     $article->title = $_POST['title'];
     $article->text = $_POST['text'];
     $article->insert();
 }
開發者ID:sydorenkovd,項目名稱:test-items,代碼行數:9,代碼來源:NewsController.php

示例3: actionAddNews

 public function actionAddNews()
 {
     $article = new ModelNews();
     $title = $_POST['title'];
     $text = $_POST['text'];
     $article->title = $title;
     $article->text = $text;
     $article->insert();
     $send = new SendMail();
     if ($send->send()) {
         header("Location: http://" . $_SERVER['SERVER_NAME'] . "/");
     } else {
         throw new \Exception("Ошибка при отправлении письма о добавлении новости!");
     }
 }
開發者ID:semho,項目名稱:customer-DB,代碼行數:15,代碼來源:Admin.php


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