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


PHP Posts::validate方法代碼示例

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


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

示例1: testPostModelValidates

 public function testPostModelValidates()
 {
     //arrange
     $post = new Posts();
     $post->title = 'GGC Test Post!';
     $post->message = 'This is a fake data blah blah blah';
     //act
     $result = $post->validate();
     //assert
     $this->assertTrue($result);
 }
開發者ID:Abenaman,項目名稱:ggc-talk,代碼行數:11,代碼來源:PostTest.php

示例2: addPost

 public static function addPost($uid)
 {
     $model = new Posts();
     $colid = zmf::filterInput($_POST['Posts']['colid']);
     $_colid = zmf::filterInput($_POST['colid']);
     $columnid = zmf::filterInput($_POST['columnid']);
     if ($colid == '0' or !$colid) {
         $colid = $columnid;
     }
     if (!$columnid) {
         $colid = $_colid;
     }
     $_POST['Posts']['colid'] = $colid;
     $intoData = $_POST['Posts'];
     if (!empty($_POST['tagname'])) {
         $tagNames = array_unique(array_filter($_POST['tagname']));
     }
     $intoKeyid = zmf::filterInput($_POST['Posts']['id'], 't', 1);
     $intoData['status'] = 1;
     $content = $_POST['Posts']['content'];
     $pattern = "/<[img|IMG].*?data=[\\'|\"](.*?)[\\'|\"].*?[\\/]?>/i";
     preg_match_all($pattern, $content, $match);
     if (!empty($match[0])) {
         $arr = array();
         foreach ($match[0] as $key => $val) {
             $_key = $match[1][$key];
             $arr[$_key] = $val;
             $arr_attachids[] = $match[1][$key];
         }
         if (!empty($arr)) {
             foreach ($arr as $thekey => $imgsrc) {
                 $content = str_ireplace("{$imgsrc}", '[attach]' . $thekey . '[/attach]', $content);
             }
         }
     }
     $attachid = zmf::filterInput($_POST['Posts']['attachid'], 't', 1);
     $intoData['content'] = $content;
     $intoData['attachid'] = $attachid;
     if ($_POST['Posts']['secretinfo'] != '') {
         $_POST['Posts']['secretinfo'] = tools::jiaMi($_POST['Posts']['secretinfo']);
     }
     $model->attributes = $intoData;
     if ($model->validate()) {
         if ($model->updateByPk($intoKeyid, $intoData)) {
             if (!empty($arr_attachids)) {
                 $ids = join(',', $arr_attachids);
                 if ($ids != '') {
                     Attachments::model()->updateAll(array('status' => Posts::STATUS_DELED), "logid={$intoKeyid} AND uid={$uid} AND classify='posts'");
                     Attachments::model()->updateAll(array('status' => Posts::STATUS_PASSED), "id IN({$ids})");
                 }
             }
             zmf::delFCache("notSavePosts{$uid}");
             return true;
         } else {
             $info = $_POST['Posts'];
         }
     } else {
         $info = $_POST['Posts'];
     }
     return $info;
 }
開發者ID:ph7pal,項目名稱:wedding,代碼行數:61,代碼來源:Publish.php


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