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


PHP SearchEngine::store方法代碼示例

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


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

示例1: index

 /**
  * Gather data from a subset of the WP tables
  * The total set is posts+comments (depending which options are enabled). The function will return this combined result as the total number of items to index
  *
  * @param integer $offset Current offset (out of total)
  * @param integer $count Number of items to index next
  * @param SearchEngine $engine Search engine to store items
  * @return array Number of items remaining, total number of items
  **/
 function index($offset, $count, $engine)
 {
     global $wpdb;
     $total_posts = $total_comments = 0;
     // Calculate how many in total
     if ($this->have_posts()) {
         $total_posts = $wpdb->get_var("SELECT COUNT(DISTINCT {$wpdb->posts}.ID) FROM {$wpdb->posts} " . $this->post_sql);
     }
     if ($this->have_comments()) {
         $total_comments = $wpdb->get_var("SELECT COUNT(DISTINCT {$wpdb->comments}.comment_ID) FROM {$wpdb->comments} " . $this->comment_sql);
     }
     $grand_total = $total_posts + $total_comments;
     // What to index?  We don't bother trying to span posts/comments - just go up to the limit of each
     if ($total_posts > 0 && $offset < $total_posts) {
         // More posts to index
         $relative = $offset;
         $rows = $wpdb->get_results("SELECT DISTINCT {$wpdb->posts}.*,{$wpdb->users}.user_login,{$wpdb->users}.user_nicename,{$wpdb->users}.display_name FROM {$wpdb->posts} LEFT JOIN {$wpdb->users} ON {$wpdb->posts}.post_author={$wpdb->users}.ID " . $this->post_sql . " ORDER BY {$wpdb->posts}.ID LIMIT {$relative},{$count}");
         foreach ((array) $rows as $row) {
             $engine->store($row->ID, $this->gather_for_post($row), $row);
         }
         return array($grand_total - count($rows) - $offset, $grand_total);
     } elseif ($total_comments > 0 && $offset < $grand_total) {
         $relative = $offset - $total_posts;
         $rows = $wpdb->get_results("SELECT DISTINCT comment_ID,comment_post_ID,comment_author,comment_author_url,comment_content FROM {$wpdb->comments} " . $this->comment_sql . " ORDER BY comment_ID LIMIT {$relative},{$count}");
         foreach ((array) $rows as $row) {
             $engine->store($row->comment_post_ID, $this->gather_for_comment($row), $row);
         }
         return array($grand_total - count($rows) - $offset, $grand_total);
     }
     // Nothing left
     return array(0, $grand_total);
 }
開發者ID:realfluid,項目名稱:umbaugh,代碼行數:41,代碼來源:spider.php


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