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


PHP Thread::find方法代码示例

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


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

示例1: post_reply

 /**
  * Process posting a reply to an existing thread
  */
 public function post_reply()
 {
     // validate data
     $data = Input::get();
     $rules = array('thread_id' => 'required', 'reply' => 'required');
     $val = Validator::make($data, $rules);
     if ($val->fails()) {
         Session::flash('status', 'reply-fail');
         return Redirect::to('/');
     } else {
         // make the post
         $post = new Post();
         $user = Auth::user();
         // add the info
         $post->user_id = $user->id;
         $post->thread_id = $data['thread_id'];
         $post->body = $data['reply'];
         $post->save();
         // add to the users posts count
         $user->posts++;
         $user->save();
         // add to the reply count in the thread
         $thread = Thread::find($data['thread_id']);
         $thread->postcount++;
         $thread->save();
         // notification for user
         Session::flash('status', 'new-post');
         // we are done, go back to the thread
         return Redirect::to('thread/view/' . $data['thread_id']);
     }
 }
开发者ID:nickfun,项目名称:funbb,代码行数:34,代码来源:thread.php

示例2: testGroupBy

 /**
  * testGroupBy method
  *
  * These tests will never pass with Postgres or Oracle as all fields in a select must be
  * part of an aggregate function or in the GROUP BY statement.
  *
  * @access public
  * @return void
  */
 function testGroupBy()
 {
     $db = ConnectionManager::getDataSource('test');
     $isStrictGroupBy = in_array($db->config['driver'], array('postgres', 'oracle', 'sqlite'));
     $message = '%s Postgres and Oracle have strict GROUP BY and are incompatible with this test.';
     if ($this->skipIf($isStrictGroupBy, $message)) {
         return;
     }
     $this->loadFixtures('Project', 'Product', 'Thread', 'Message', 'Bid');
     $Thread = new Thread();
     $Product = new Product();
     $result = $Thread->find('all', array('group' => 'Thread.project_id', 'order' => 'Thread.id ASC'));
     $expected = array(array('Thread' => array('id' => 1, 'project_id' => 1, 'name' => 'Project 1, Thread 1'), 'Project' => array('id' => 1, 'name' => 'Project 1'), 'Message' => array(array('id' => 1, 'thread_id' => 1, 'name' => 'Thread 1, Message 1'))), array('Thread' => array('id' => 3, 'project_id' => 2, 'name' => 'Project 2, Thread 1'), 'Project' => array('id' => 2, 'name' => 'Project 2'), 'Message' => array(array('id' => 3, 'thread_id' => 3, 'name' => 'Thread 3, Message 1'))));
     $this->assertEqual($result, $expected);
     $rows = $Thread->find('all', array('group' => 'Thread.project_id', 'fields' => array('Thread.project_id', 'COUNT(*) AS total')));
     $result = array();
     foreach ($rows as $row) {
         $result[$row['Thread']['project_id']] = $row[0]['total'];
     }
     $expected = array(1 => 2, 2 => 1);
     $this->assertEqual($result, $expected);
     $rows = $Thread->find('all', array('group' => 'Thread.project_id', 'fields' => array('Thread.project_id', 'COUNT(*) AS total'), 'order' => 'Thread.project_id'));
     $result = array();
     foreach ($rows as $row) {
         $result[$row['Thread']['project_id']] = $row[0]['total'];
     }
     $expected = array(1 => 2, 2 => 1);
     $this->assertEqual($result, $expected);
     $result = $Thread->find('all', array('conditions' => array('Thread.project_id' => 1), 'group' => 'Thread.project_id'));
     $expected = array(array('Thread' => array('id' => 1, 'project_id' => 1, 'name' => 'Project 1, Thread 1'), 'Project' => array('id' => 1, 'name' => 'Project 1'), 'Message' => array(array('id' => 1, 'thread_id' => 1, 'name' => 'Thread 1, Message 1'))));
     $this->assertEqual($result, $expected);
     $result = $Thread->find('all', array('conditions' => array('Thread.project_id' => 1), 'group' => 'Thread.project_id, Project.id'));
     $this->assertEqual($result, $expected);
     $result = $Thread->find('all', array('conditions' => array('Thread.project_id' => 1), 'group' => 'project_id'));
     $this->assertEqual($result, $expected);
     $result = $Thread->find('all', array('conditions' => array('Thread.project_id' => 1), 'group' => array('project_id')));
     $this->assertEqual($result, $expected);
     $result = $Thread->find('all', array('conditions' => array('Thread.project_id' => 1), 'group' => array('project_id', 'Project.id')));
     $this->assertEqual($result, $expected);
     $result = $Thread->find('all', array('conditions' => array('Thread.project_id' => 1), 'group' => array('Thread.project_id', 'Project.id')));
     $this->assertEqual($result, $expected);
     $expected = array(array('Product' => array('type' => 'Clothing'), array('price' => 32)), array('Product' => array('type' => 'Food'), array('price' => 9)), array('Product' => array('type' => 'Music'), array('price' => 4)), array('Product' => array('type' => 'Toy'), array('price' => 3)));
     $result = $Product->find('all', array('fields' => array('Product.type', 'MIN(Product.price) as price'), 'group' => 'Product.type', 'order' => 'Product.type ASC'));
     $this->assertEqual($result, $expected);
     $result = $Product->find('all', array('fields' => array('Product.type', 'MIN(Product.price) as price'), 'group' => array('Product.type'), 'order' => 'Product.type ASC'));
     $this->assertEqual($result, $expected);
 }
开发者ID:robotarmy,项目名称:Phog,代码行数:56,代码来源:model_read.test.php

示例3: testGroupBy

 /**
  * testGroupBy method
  *
  * These tests will never pass with Postgres or Oracle as all fields in a select must be
  * part of an aggregate function or in the GROUP BY statement.
  *
  * @return void
  */
 public function testGroupBy()
 {
     $db = ConnectionManager::getDataSource('test');
     $isStrictGroupBy = $this->db instanceof Postgres || $this->db instanceof Sqlite || $this->db instanceof Oracle || $this->db instanceof Sqlserver;
     $message = 'Postgres, Oracle, SQLite and SQL Server have strict GROUP BY and are incompatible with this test.';
     $this->skipIf($isStrictGroupBy, $message);
     $this->loadFixtures('Project', 'Product', 'Thread', 'Message', 'Bid');
     $Thread = new Thread();
     $Product = new Product();
     $result = $Thread->find('all', array('group' => 'Thread.project_id', 'order' => 'Thread.id ASC'));
     $expected = array(array('Thread' => array('id' => 1, 'project_id' => 1, 'name' => 'Project 1, Thread 1'), 'Project' => array('id' => 1, 'name' => 'Project 1'), 'Message' => array(array('id' => 1, 'thread_id' => 1, 'name' => 'Thread 1, Message 1'))), array('Thread' => array('id' => 3, 'project_id' => 2, 'name' => 'Project 2, Thread 1'), 'Project' => array('id' => 2, 'name' => 'Project 2'), 'Message' => array(array('id' => 3, 'thread_id' => 3, 'name' => 'Thread 3, Message 1'))));
     $this->assertEquals($expected, $result);
     $rows = $Thread->find('all', array('group' => 'Thread.project_id', 'fields' => array('Thread.project_id', 'COUNT(*) AS total')));
     $result = array();
     foreach ($rows as $row) {
         $result[$row['Thread']['project_id']] = $row[0]['total'];
     }
     $expected = array(1 => 2, 2 => 1);
     $this->assertEquals($expected, $result);
     $rows = $Thread->find('all', array('group' => 'Thread.project_id', 'fields' => array('Thread.project_id', 'COUNT(*) AS total'), 'order' => 'Thread.project_id'));
     $result = array();
     foreach ($rows as $row) {
         $result[$row['Thread']['project_id']] = $row[0]['total'];
     }
     $expected = array(1 => 2, 2 => 1);
     $this->assertEquals($expected, $result);
     $result = $Thread->find('all', array('conditions' => array('Thread.project_id' => 1), 'group' => 'Thread.project_id'));
     $expected = array(array('Thread' => array('id' => 1, 'project_id' => 1, 'name' => 'Project 1, Thread 1'), 'Project' => array('id' => 1, 'name' => 'Project 1'), 'Message' => array(array('id' => 1, 'thread_id' => 1, 'name' => 'Thread 1, Message 1'))));
     $this->assertEquals($expected, $result);
     $result = $Thread->find('all', array('conditions' => array('Thread.project_id' => 1), 'group' => 'Thread.project_id, Project.id'));
     $this->assertEquals($expected, $result);
     $result = $Thread->find('all', array('conditions' => array('Thread.project_id' => 1), 'group' => 'project_id'));
     $this->assertEquals($expected, $result);
     $result = $Thread->find('all', array('conditions' => array('Thread.project_id' => 1), 'group' => array('project_id')));
     $this->assertEquals($expected, $result);
     $result = $Thread->find('all', array('conditions' => array('Thread.project_id' => 1), 'group' => array('project_id', 'Project.id')));
     $this->assertEquals($expected, $result);
     $result = $Thread->find('all', array('conditions' => array('Thread.project_id' => 1), 'group' => array('Thread.project_id', 'Project.id')));
     $this->assertEquals($expected, $result);
     $expected = array(array('Product' => array('type' => 'Clothing'), array('price' => 32)), array('Product' => array('type' => 'Food'), array('price' => 9)), array('Product' => array('type' => 'Music'), array('price' => 4)), array('Product' => array('type' => 'Toy'), array('price' => 3)));
     $result = $Product->find('all', array('fields' => array('Product.type', 'MIN(Product.price) as price'), 'group' => 'Product.type', 'order' => 'Product.type ASC'));
     $this->assertEquals($expected, $result);
     $result = $Product->find('all', array('fields' => array('Product.type', 'MIN(Product.price) as price'), 'group' => array('Product.type'), 'order' => 'Product.type ASC'));
     $this->assertEquals($expected, $result);
 }
开发者ID:eboominathan,项目名称:Basic-CRUD-in-CakePHP-,代码行数:53,代码来源:ModelReadTest.php

示例4: check_thread_rights

 public static function check_thread_rights($thread_id)
 {
     $user = self::get_user_logged_in();
     $thread = new Thread(Thread::find($thread_id));
     $id = $thread->user_id;
     if ($user->userrole != 'ADMIN' && $user->id != $id) {
         Redirect::to('/', array('message' => 'You have no authority to perform that action.'));
     }
 }
开发者ID:CarnivoreBarnacle,项目名称:Forum,代码行数:9,代码来源:base_controller.php

示例5: addMessage

 public static function addMessage($thread_id)
 {
     $params = $_POST;
     $time = date('Y-m-d G:i:s');
     $attributes = array('content' => $params['content'], 'created' => $time, 'user_id' => $_SESSION['user'], 'thread_id' => $thread_id);
     $message = new Message($attributes);
     $errors = $message->errors();
     if (count($errors) == 0) {
         $message->save();
         //Updating lastpost of thread
         $thread = new Thread(Thread::find($thread_id));
         $thread->updateLastpost($time);
         //Updating participants list
         $user = new ForumUser(ForumUser::find($_SESSION['user']));
         ForumUser::changePostAmount($user->id, $thread_id, 1);
         Redirect::to('/thread/' . $thread_id);
     } else {
         $thread = new Thread(Thread::find($thread_id));
         View::make('message/message_create.html', array('thread' => $thread, 'errors' => $errors, 'attributes' => $attributes));
     }
 }
开发者ID:CarnivoreBarnacle,项目名称:Forum,代码行数:21,代码来源:message_controller.php

示例6: managepost

 public function managepost($id, $name)
 {
     $id_len = strlen($id);
     $forum_id = substr($id, 0, 1);
     $thread_id = substr($id, 1, $id_len - 1);
     $thread = Thread::find($thread_id);
     $user_id = Session::get('WebUserId');
     if (Input::get('submit') == 'post') {
         if (Input::get('text') != '') {
             $post = new Post();
             $post->text = Input::get('text');
             $post->webuser_id = $user_id;
             $post->thread_id = $thread_id;
             $post->save();
             $thread->updated_at = time();
             $thread->lastuser_id = $user_id;
             $thread->save();
             $view = ForumViewCount::find($forum_id);
             $view->post = $view->post + 1;
             $view->save();
         }
     } elseif (Input::get('submit') == 'manage') {
         if (Input::get('action') == 'close') {
             $thread->status = 1;
             $thread->icon = 'lock';
             $thread->save();
         } else {
             if (Input::get('action') == 'open') {
                 $thread->status = 2;
                 $thread->icon = 'lock-open';
                 $thread->save();
             } else {
                 if (Input::get('action') == 'stick') {
                     $thread->status = 3;
                     $thread->icon = 'publish';
                     $thread->save();
                 } else {
                     if (Input::get('action') == 'unstick') {
                         $thread->status = 2;
                         $thread->icon = 'chat';
                         $thread->save();
                     } else {
                         if (Input::get('action') == 'del') {
                             $thread->status = 0;
                             $thread->save();
                             return Redirect::to('/dien-dan.html');
                         }
                     }
                 }
             }
         }
     } elseif (Input::get('postid') != NULL) {
         $postedit = Post::find(Input::get('postid'));
         $postedit->text = Input::get('text');
         $postedit->save();
     } elseif (Input::get('submit') == 'editthread') {
         $thread->title = Input::get('title');
         $thread->forum = Input::get('destination');
         $thread->save();
     }
     return Redirect::to("/dien-dan/" . $id . "/" . $name);
 }
开发者ID:Gouken,项目名称:WebMuApp,代码行数:62,代码来源:Front.php

示例7: get_thread_status

function get_thread_status($threadid)
{
    //--Konunun Açık,Kapalı,Silinmiş ya da görünmez olduğunu öğrenmek için.
    $thread = Thread::find($threadid)->first();
    return $thread->type;
}
开发者ID:TahsinGokalp,项目名称:L3-Sozluk,代码行数:6,代码来源:helpers.php

示例8: get_id

 public function get_id($id = 0)
 {
     if (!empty($id)) {
         $entry = Post::with('author')->where_id($id)->first();
     }
     /*Getting the thread*/
     $thread = Thread::find($entry->thread_id);
     if (Request::ajax()) {
         $view = View::make('entry.one-entryajax');
         $view->entry = $entry;
         $view->thread = $thread;
         return $view;
     } else {
         $view = View::make('entry.one-entry');
         $view->title = '#' . $entry->id . ' ' . substr(strip_tags(trim(strtolower($entry->entry))), 0, 20) . " ... ";
         $view->entry = $entry;
         $view->thread = $thread;
         return $view;
     }
 }
开发者ID:TahsinGokalp,项目名称:L3-Sozluk,代码行数:20,代码来源:entry.php

示例9: destroyThread

 public static function destroyThread($id)
 {
     $thread = new Thread(Thread::find($id));
     $thread->delete();
     Redirect::to('/thread', array('message' => 'Thread deleted.'));
 }
开发者ID:CarnivoreBarnacle,项目名称:Forum,代码行数:6,代码来源:thread_controller.php


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