当前位置: 首页>>代码示例>>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;未经允许,请勿转载。