当前位置: 首页>>代码示例>>PHP>>正文


PHP Thread::save方法代码示例

本文整理汇总了PHP中Thread::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Thread::save方法的具体用法?PHP Thread::save怎么用?PHP Thread::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Thread的用法示例。


在下文中一共展示了Thread::save方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionCreate

 public function actionCreate($id)
 {
     $forum = Forum::model()->findByPk($id);
     if (null == $forum) {
         throw new CHttpException(404, 'Forum not found.');
     }
     if ($forum->is_locked && (Yii::app()->user->isGuest || !Yii::app()->user->isForumAdmin())) {
         throw new CHttpException(403, 'Forum is locked.');
     }
     $model = new PostForm();
     $model->setScenario('create');
     // This makes subject required
     if (isset($_POST['PostForm'])) {
         if (!isset($_POST['YII_CSRF_TOKEN']) || $_POST['YII_CSRF_TOKEN'] != Yii::app()->getRequest()->getCsrfToken()) {
             throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
         }
         $model->attributes = $_POST['PostForm'];
         if ($model->validate()) {
             $thread = new Thread();
             $thread->forum_id = $forum->id;
             $thread->subject = $model->subject;
             $thread->author_id = Yii::app()->user->id;
             $thread->lastPost_user_id = Yii::app()->user->id;
             $thread->lastPost_time = time();
             $thread->save(false);
             $post = new Post();
             $post->author_id = Yii::app()->user->id;
             $post->thread_id = $thread->id;
             $post->content = $model->content;
             $post->save(false);
             $this->redirect($thread->url);
         }
     }
     $this->render('newThread', array('forum' => $forum, 'model' => $model));
 }
开发者ID:CrystReal,项目名称:Site_frontend,代码行数:35,代码来源:ThreadController.php

示例2: testCreate

 public function testCreate()
 {
     $thread = new Thread();
     $thread->crashreport_id = 1;
     $thread->thread_id = 4094;
     $thread->stack_trace_md5 = '1234567890123456789012';
     $saved = $thread->save();
     $this->assertTrue($saved);
     // Find created model
     $model = Thread::model()->findByAttributes(array('thread_id' => 4094));
     $this->assertTrue($model != null);
 }
开发者ID:xyzz,项目名称:CrashFix,代码行数:12,代码来源:ThreadTest.php

示例3: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Thread();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Thread'])) {
         $model->attributes = $_POST['Thread'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->thread_id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:vsanth,项目名称:yii-customer-database,代码行数:17,代码来源:ThreadController.php

示例4: addThread

 public static function addThread()
 {
     $params = $_POST;
     $time = date('Y-m-d G:i:s');
     $attributes = array('name' => $params['name'], 'created' => $time, 'lastpost' => $time, 'user_id' => $_SESSION['user']);
     $thread = new Thread($attributes);
     $errors = $thread->errors();
     if (count($errors) == 0) {
         $thread->save();
         Redirect::to('/thread/' . $thread->id);
     } else {
         View::make('thread/thread_create.html', array('errors' => $errors, 'attributes' => $attributes));
     }
 }
开发者ID:CarnivoreBarnacle,项目名称:Forum,代码行数:14,代码来源:thread_controller.php

示例5: executeSendMessage

 public function executeSendMessage(sfWebRequest $request)
 {
     $this->forward404Unless($request->isMethod('POST'));
     $form = new MessageForm($this->getUser()->getAttribute('id'));
     $form->bind($request->getParameter('message'));
     if ($form->isValid()) {
         $thread = new Thread();
         $thread->subject = $request->getPostParameter('message[subject]');
         $thread->recipients = json_encode(array($this->getUser()->getAttribute('id'), $request->getPostParameter('message[recipients]')));
         $thread->save();
         $message = new Message();
         $message->message_id = md5(date(DateTime::ISO8601));
         $message->thread_id = $thread->thread_id;
         $message->author_id = $this->getUser()->getAttribute('id');
         $message->body = $request->getPostParameter('message[message]');
         $message->save();
         $this->redirectWithInfo('Your message was successfully sent.', 'messages/index');
     }
     $this->redirectWithInfo('An error occured sending your message.  Please try again later.');
 }
开发者ID:rsanders16,项目名称:NexusPlus,代码行数:20,代码来源:actions.class.php

示例6: testSaveEmpty

 /**
  * testSaveEmpty method
  *
  * @return void
  */
 public function testSaveEmpty()
 {
     $this->loadFixtures('Thread');
     $TestModel = new Thread();
     $data = array();
     $expected = $TestModel->save($data);
     $this->assertFalse($expected);
 }
开发者ID:TerrasAppSolutions,项目名称:seeg-mapbiomas-workspace,代码行数:13,代码来源:ModelReadTest.php

示例7: createthread

 public function createthread($name)
 {
     if ($name == 'thong-bao.html') {
         $forum = 1;
     } else {
         if ($name == 'thao-luan-chung.html') {
             $forum = 2;
         } else {
             if ($name == 'dong-gop-y-kien.html') {
                 $forum = 3;
             } else {
                 if ($name == 'buon-ban.html') {
                     $forum = 4;
                 } else {
                     if ($name == 'kinh-nghiem-choi.html') {
                         $forum = 5;
                     } else {
                         if ($name == 'bang-hoi.html') {
                             $forum = 6;
                         } else {
                             if ($name == 'report-loi-game.html') {
                                 $forum = 7;
                             } else {
                                 return Redirect::to('/dien-dan.html');
                             }
                         }
                     }
                 }
             }
         }
     }
     $title = Input::get('title');
     $text = Input::get('text');
     $user_id = Session::get('WebUserId');
     $thread = new Thread();
     $thread->webuser_id = $user_id;
     $thread->forum = $forum;
     $thread->title = $title;
     $thread->reply = 0;
     $thread->lastuser_id = $user_id;
     $thread->created_at = time();
     $thread->updated_at = time();
     $thread->save();
     $first_post = new Post();
     $first_post->webuser_id = $user_id;
     $first_post->thread_id = $thread->id;
     $first_post->text = $text;
     $first_post->save();
     $view = ForumViewCount::find($forum);
     $view->topic = $view->topic + 1;
     $view->save();
     return Redirect::to("/dien-dan/" . $name);
 }
开发者ID:Gouken,项目名称:WebMuApp,代码行数:53,代码来源:Front.php

示例8: post_new

 /**
  * Make a new thread
  */
 public function post_new()
 {
     $data = Input::get();
     $rules = array('board_id' => 'required', 'subject' => 'required', 'body' => 'required');
     $val = Validator::make($data, $rules);
     if ($val->fails()) {
         return Redirect::to('/')->with_input()->with_errors($val);
     } else {
         // make the thread!
         $user = Auth::user();
         $thread = new Thread();
         $thread->board_id = $data['board_id'];
         $thread->user_id = $user->id;
         $thread->subject = $data['subject'];
         $thread->postcount = 1;
         $thread->save();
         // make the 1st post
         $post = new Post();
         $post->user_id = $user->id;
         $post->thread_id = $thread->id;
         $post->body = $data['body'];
         $post->save();
         // update the users post count
         $user->posts++;
         $user->save();
         return Redirect::to('thread/view/' . $thread->id);
     }
     return Response::json($data);
 }
开发者ID:nickfun,项目名称:funbb,代码行数:32,代码来源:thread.php

示例9: makeNewThread

 /**
  * Makes a new thread by this user
  *
  * @param int $forumID
  * @param string $threadTitle
  * @param string $postBody
  * @return bool
  */
 public function makeNewThread($forumID, $threadTitle, $postBody, $cat_id, $notify_email, $notify_pm, $tags, $school_grade)
 {
     //If the user is banned, they can't make a new thread
     if ($this->getHidden()) {
         return false;
     }
     //Create the thread
     $thread = new Thread();
     $thread->setTitle($threadTitle);
     $thread->setPosterId($this->getId());
     $thread->setForumId($forumID);
     $thread->setCategoryId($cat_id);
     $thread->setNotifyEmail($notify_email);
     $thread->setNotifyPm($notify_pm);
     //	$thread->setNotifySms($notify_sms);
     //	$thread->setCellNumber($cell_number);
     $thread->setTags($tags);
     $thread->setSchoolGrade($school_grade);
     //If the thread wasn't properly added to the DB, return false
     if (!$thread->save()) {
         return false;
     }
     //Create the first post
     return $this->makeNewPost($thread->getId(), $postBody);
 }
开发者ID:rayku,项目名称:rayku,代码行数:33,代码来源:User.php

示例10: createthread

 public function createthread($name)
 {
     $forums = HelperFunctions::forum_list();
     foreach ($forums as $key => $f) {
         if ($f[0] == $name) {
             $forum = $key + 1;
         }
     }
     if ($forum == 0) {
         return Redirect::to("/dien-dan.html");
     }
     $title = Input::get('title');
     $text = Input::get('text');
     $user_id = Session::get('WebUserId');
     $thread = new Thread();
     $thread->webuser_id = $user_id;
     $thread->forum = $forum;
     $thread->title = $title;
     $thread->reply = 0;
     $thread->lastuser_id = $user_id;
     $thread->created_at = time();
     $thread->updated_at = time();
     $thread->save();
     $first_post = new Post();
     $first_post->webuser_id = $user_id;
     $first_post->thread_id = $thread->id;
     $first_post->text = $text;
     $first_post->save();
     $last_post_seed = new Post();
     $last_post_seed->webuser_id = $user_id;
     $last_post_seed->thread_id = $thread->id;
     $last_post_seed->text = 'seed_for_textbox';
     $last_post_seed->status = 1;
     $last_post_seed->save();
     $view = ForumViewCount::find($forum);
     $view->topic = $view->topic + 1;
     $view->save();
     return Redirect::to("/dien-dan/" . $name);
 }
开发者ID:Gouken,项目名称:WebMuApp,代码行数:39,代码来源:FlatFront.php

示例11: importCrashReportFromXml


//.........这里部分代码省略.........
         if (!$crashReport->validate()) {
             // There are some errors
             $errors = $crashReport->getErrors();
             foreach ($errors as $fieldName => $fieldErrors) {
                 foreach ($fieldErrors as $errorMsg) {
                     // Add an error message to log
                     Yii::log('Error in crashreport data (' . $crashReport->{$fieldName} . '): ' . $errorMsg, 'error');
                     // Associate a processing error with crash report record
                     $this->addProcessingError(ProcessingError::TYPE_CRASH_REPORT_ERROR, $crashReport->id, $errorMsg . ' (' . $crashReport->{$fieldName} . ')');
                     // Clear field - this should fix the error
                     unset($crashReport->{$fieldName});
                 }
             }
             // Clear validation errors
             $crashReport->clearErrors();
         }
         // Extract file items
         $elemFileList = $doc->FileList;
         if ($elemFileList != Null) {
             $i = 0;
             foreach ($elemFileList->Row as $elemRow) {
                 $i++;
                 if ($i == 1) {
                     continue;
                 }
                 // Skip header row
                 $itemNo = $elemRow->Cell[0]['val'];
                 $itemName = $elemRow->Cell[1]['val'];
                 $itemDesc = $elemRow->Cell[2]['val'];
                 $fileItem = new FileItem();
                 $fileItem->filename = $itemName;
                 $fileItem->description = $itemDesc;
                 $fileItem->crashreport_id = $crashReportId;
                 if (!$fileItem->save()) {
                     throw new Exception('Could not save file item record');
                 }
             }
         }
         // Extract custom props
         $elemAppDefinedProps = $doc->ApplicationDefinedProperties;
         if ($elemAppDefinedProps != Null) {
             $i = 0;
             foreach ($elemAppDefinedProps->Row as $elemRow) {
                 $i++;
                 if ($i == 1) {
                     continue;
                 }
                 // Skip header row
                 $itemNo = $elemRow->Cell[0]['val'];
                 $name = $elemRow->Cell[1]['val'];
                 $val = $elemRow->Cell[2]['val'];
                 $customProp = new CustomProp();
                 $customProp->name = $name;
                 $customProp->value = $val;
                 $customProp->crashreport_id = $crashReportId;
                 if (!$customProp->save()) {
                     throw new Exception('Could not save custom property record');
                 }
             }
         }
         // Extract the list of modules
         $elemModuleList = $doc->ModuleList;
         if ($elemModuleList != Null && $elemModuleList->count() != 0) {
             $i = 0;
             foreach ($elemModuleList->Row as $elemRow) {
                 $i++;
开发者ID:xyzz,项目名称:CrashFix,代码行数:67,代码来源:PollCommand.php


注:本文中的Thread::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。