Esempio n. 1
0
 /**
  * Public factory method to create a post object
  *
  * @param int $id
  * @param boolean $autoloadthread if true, load the thread data on instantiation
  * @return vB_Legacy_Post
  */
 public static function create_from_id($id, $autoloadthread = false)
 {
     global $vbulletin;
     if (!$autoloadthread) {
         $post = $vbulletin->db->query_first_slave("\n\t\t\t\tSELECT * FROM " . TABLE_PREFIX . "post WHERE postid = " . intval($id));
         if (!$post) {
             return false;
         } else {
             return self::create_from_record($post);
         }
     } else {
         $post_fields = vB_Legacy_Post::get_field_names();
         $thread_fields = vB_Legacy_Thread::get_field_names();
         $select = array();
         foreach ($post_fields as $field) {
             $select[] = 'p.' . $field;
         }
         foreach ($thread_fields as $field) {
             $select[] = 't.' . $field;
         }
         $row = $vbulletin->db->query_first_slave($q = "\n\t\t\t\tSELECT " . implode(', ', $select) . "\n\t\t\t\tFROM " . TABLE_PREFIX . "post as p join " . TABLE_PREFIX . "thread as t ON p.threadid = t.threadid\n\t\t\t \tWHERE p.postid = " . intval($id), DBARRAY_NUM);
         if (!$row) {
             return null;
         }
         $post_data = array_combine($post_fields, array_slice($row, 0, count($post_fields)));
         $thread_data = array_combine($thread_fields, array_slice($row, count($post_fields)));
         return vB_Legacy_Post::create_from_record($post_data, $thread_data);
     }
 }
Esempio n. 2
0
 /**
  * Index a range of posts
  *
  * @param unknown_type $start
  * @param unknown_type $end
  */
 public function index_id_range($start, $end)
 {
     global $vbulletin;
     $indexer = vB_Search_Core::get_instance()->get_core_indexer();
     $post_fields = vB_Legacy_Post::get_field_names();
     $thread_fields = vB_Legacy_Thread::get_field_names();
     $select = array();
     foreach ($post_fields as $field) {
         $select[] = 'p.' . $field;
     }
     foreach ($thread_fields as $field) {
         $select[] = 't.' . $field;
     }
     $set = $vbulletin->db->query("\n\t\t\tSELECT " . implode(', ', $select) . "\n\t\t\tFROM " . TABLE_PREFIX . "post as p join " . TABLE_PREFIX . "thread as t ON p.threadid = t.threadid\n\t\t\tWHERE p.postid >= " . intval($start) . " AND p.postid <= " . intval($end));
     while ($row = $vbulletin->db->fetch_row($set)) {
         //The assumption that cached thread lookups were fast enough seems to have been good.
         //however the memory requirements for long ranges added up fast, so we'll try pulling
         //the thread data with the posts.
         //Now we need to honor the "indexposts" setting in the forum.
         $forum = fetch_foruminfo($row[count($post_fields) + 3]);
         //The forum object has the necessary information
         if (!$forum['indexposts']) {
             continue;
         }
         $post_data = array_combine($post_fields, array_slice($row, 0, count($post_fields)));
         $thread_data = array_combine($thread_fields, array_slice($row, count($post_fields)));
         $post = vB_Legacy_Post::create_from_record($post_data, $thread_data);
         $fields = $this->post_to_indexfields($post);
         if ($fields) {
             $indexer->index($fields);
             $this->range_indexed++;
         }
     }
     $vbulletin->db->free_result($set);
 }