当前位置: 首页>>代码示例>>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;未经允许,请勿转载。