sql

 SELECT  COMdigestlifer_posts.id FROM COMdigestlifer_posts  LEFT JOIN COMdigestlifer_term_relationships AS trel ON (COMdigestlifer_posts.ID = trel.object_id) LEFT JOIN COMdigestlifer_term_taxonomy AS ttax ON (  ( ttax.taxonomy = 'category' OR ttax.taxonomy = 'post_tag' OR ttax.taxonomy = 'post_format' )  AND trel.term_taxonomy_id = ttax.term_taxonomy_id) LEFT JOIN COMdigestlifer_terms AS tter ON (ttax.term_id = tter.term_id)  WHERE 1=1 AND ( ( (((((COMdigestlifer_posts.post_title LIKE '%mobile%') OR (COMdigestlifer_posts.post_content LIKE '%mobile%')) AND ((COMdigestlifer_posts.post_title LIKE '%phone%') OR (COMdigestlifer_posts.post_content LIKE '%phone%'))) OR (((tter.name LIKE '%mobile%') AND (tter.name LIKE '%phone%')) OR (tter.name LIKE '%mobile+phone%')) ))  AND (COMdigestlifer_posts.post_password = '')  AND COMdigestlifer_posts.post_type IN ('post', 'page', 'attachment') AND (COMdigestlifer_posts.post_status = 'publish')) AND post_type != 'revision') AND post_status != 'future'  ORDER BY COMdigestlifer_posts.post_date DESC LIMIT 45, 5
 
 
 SELECT SQL_CALC_FOUND_ROWS  COMdigestlifer_posts.* FROM COMdigestlifer_posts  LEFT JOIN COMdigestlifer_term_relationships AS trel ON (COMdigestlifer_posts.ID = trel.object_id) LEFT JOIN COMdigestlifer_term_taxonomy AS ttax ON (  ( ttax.taxonomy = 'category' OR ttax.taxonomy = 'post_tag' OR ttax.taxonomy = 'post_format' )  AND trel.term_taxonomy_id = ttax.term_taxonomy_id) LEFT JOIN COMdigestlifer_terms AS tter ON (ttax.term_id = tter.term_id)  WHERE COMdigestlifer_posts.id IN (14897,14897,14897,14897,14897)  ORDER BY COMdigestlifer_posts.post_date DESC

 


 
SELECT SQL_CALC_FOUND_ROWS  COMdigestlifer_posts.* FROM COMdigestlifer_posts  LEFT JOIN COMdigestlifer_term_relationships AS trel ON (COMdigestlifer_posts.ID = trel.object_id) LEFT JOIN COMdigestlifer_term_taxonomy AS ttax ON (  ( ttax.taxonomy = 'category' OR ttax.taxonomy = 'post_tag' OR ttax.taxonomy = 'post_format' )  AND trel.term_taxonomy_id = ttax.term_taxonomy_id) LEFT JOIN COMdigestlifer_terms AS tter ON (ttax.term_id = tter.term_id)  WHERE 1=1 AND ( ( (((((COMdigestlifer_posts.post_title LIKE '%mobile%') OR (COMdigestlifer_posts.post_content LIKE '%mobile%')) AND ((COMdigestlifer_posts.post_title LIKE '%phone%') OR (COMdigestlifer_posts.post_content LIKE '%phone%'))) OR (((tter.name LIKE '%mobile%') AND (tter.name LIKE '%phone%')) OR (tter.name LIKE '%mobile+phone%')) ))  AND (COMdigestlifer_posts.post_password = '')  AND COMdigestlifer_posts.post_type IN ('post', 'page', 'attachment') AND (COMdigestlifer_posts.post_status = 'publish')) AND post_type != 'revision') AND post_status != 'future'  ORDER BY COMdigestlifer_posts.post_date DESC LIMIT 45, 5

 

 SELECT  COMdigestlifer_posts.id FROM COMdigestlifer_posts  LEFT JOIN COMdigestlifer_term_relationships AS trel ON (COMdigestlifer_posts.ID = trel.object_id) LEFT JOIN COMdigestlifer_term_taxonomy AS ttax ON (  ( ttax.taxonomy = 'category' OR ttax.taxonomy = 'post_tag' OR ttax.taxonomy = 'post_format' )  AND trel.term_taxonomy_id = ttax.term_taxonomy_id) LEFT JOIN COMdigestlifer_terms AS tter ON (ttax.term_id = tter.term_id)  WHERE 1=1 AND ( ( (((((COMdigestlifer_posts.post_title LIKE '%mobile%') OR (COMdigestlifer_posts.post_content LIKE '%mobile%')) AND ((COMdigestlifer_posts.post_title LIKE '%phone%') OR (COMdigestlifer_posts.post_content LIKE '%phone%'))) OR (((tter.name LIKE '%mobile%') AND (tter.name LIKE '%phone%')) OR (tter.name LIKE '%mobile+phone%')) ))  AND (COMdigestlifer_posts.post_password = '')  AND COMdigestlifer_posts.post_type IN ('post', 'page', 'attachment') AND (COMdigestlifer_posts.post_status = 'publish')) AND post_type != 'revision') AND post_status != 'future'  ORDER BY COMdigestlifer_posts.post_date DESC LIMIT 45, 5
14897,14897,14897,14897,14897
 SELECT SQL_CALC_FOUND_ROWS  COMdigestlifer_posts.* FROM COMdigestlifer_posts  LEFT JOIN COMdigestlifer_term_relationships AS trel ON (COMdigestlifer_posts.ID = trel.object_id) LEFT JOIN COMdigestlifer_term_taxonomy AS ttax ON (  ( ttax.taxonomy = 'category' OR ttax.taxonomy = 'post_tag' OR ttax.taxonomy = 'post_format' )  AND trel.term_taxonomy_id = ttax.term_taxonomy_id) LEFT JOIN COMdigestlifer_terms AS tter ON (ttax.term_id = tter.term_id)  WHERE COMdigestlifer_posts.id IN (14897,14897,14897,14897,14897)  ORDER BY COMdigestlifer_posts.post_date DESC


 SELECT DISTINCT SQL_CALC_FOUND_ROWS  COMdigestlifer_posts.* FROM COMdigestlifer_posts  LEFT JOIN COMdigestlifer_term_relationships AS trel ON (COMdigestlifer_posts.ID = trel.object_id) LEFT JOIN COMdigestlifer_term_taxonomy AS ttax ON (  ( ttax.taxonomy = 'category' OR ttax.taxonomy = 'post_tag' OR ttax.taxonomy = 'post_format' )  AND trel.term_taxonomy_id = ttax.term_taxonomy_id) LEFT JOIN COMdigestlifer_terms AS tter ON (ttax.term_id = tter.term_id)  WHERE COMdigestlifer_posts.id IN (14897,14897,14897,14897,14897)  ORDER BY COMdigestlifer_posts.post_date DESC

 ---------------------------------------

# Time: 121119 16:59:19
# User@Host: -[-] @ localhost []
# Query_time: 13.842594  Lock_time: 0.000112 Rows_sent: 5  Rows_examined: 596864
SET timestamp=1353333559;
SELECT DISTINCT SQL_CALC_FOUND_ROWS  COMdigestlifer_posts.* FROM COMdigestlifer_posts  LEFT JOIN COMdigestlifer_term_relationships AS trel ON (COMdigestlifer_posts.ID = trel.object_id) LEFT JOIN COMdigestlifer_term_taxonomy AS ttax ON (  ( ttax.taxonomy = 'category' OR ttax.taxonomy = 'post_tag' OR ttax.taxonomy = 'post_format' )  AND trel.term_taxonomy_id = ttax.term_taxonomy_id) LEFT JOIN COMdigestlifer_terms AS tter ON (ttax.term_id = tter.term_id)  WHERE 1=1 AND ( ( (((((COMdigestlifer_posts.post_title LIKE '%touch%') OR (COMdigestlifer_posts.post_content LIKE '%touch%')) AND ((COMdigestlifer_posts.post_title LIKE '%screen%') OR (COMdigestlifer_posts.post_content LIKE '%screen%'))) OR (((tter.name LIKE '%touch%') AND (tter.name LIKE '%screen%')) OR (tter.name LIKE '%touch+screen%')) ))  AND (COMdigestlifer_posts.post_password = '')  AND COMdigestlifer_posts.post_type IN ('post', 'page', 'attachment') AND (COMdigestlifer_posts.post_status = 'publish')) AND post_type != 'revision') AND post_status != 'future'  ORDER BY COMdigestlifer_posts.post_date DESC LIMIT 0, 5;

模板中:

# Time: 121119 16:59:34
# User@Host: -[-] @ localhost []
# Query_time: 14.654413  Lock_time: 0.000130 Rows_sent: 1  Rows_examined: 645829
SET timestamp=1353333574;
SELECT COUNT(DISTINCT ID) FROM COMdigestlifer_posts  LEFT JOIN COMdigestlifer_term_relationships AS trel ON (COMdigestlifer_posts.ID = trel.object_id) LEFT JOIN COMdigestlifer_term_taxonomy AS ttax ON (  ( ttax.taxonomy = 'category' OR ttax.taxonomy = 'post_tag' OR ttax.taxonomy = 'post_format' )  AND trel.term_taxonomy_id = ttax.term_taxonomy_id) LEFT JOIN COMdigestlifer_terms AS tter ON (ttax.term_id = tter.term_id)  WHERE 1=1 AND ( ( (((((COMdigestlifer_posts.post_title LIKE '%touch%') OR (COMdigestlifer_posts.post_content LIKE '%touch%')) AND ((COMdigestlifer_posts.post_title LIKE '%screen%') OR (COMdigestlifer_posts.post_content LIKE '%screen%'))) OR (((tter.name LIKE '%touch%') AND (tter.name LIKE '%screen%')) OR (tter.name LIKE '%touch+screen%')) ))  AND (COMdigestlifer_posts.post_password = '')  AND COMdigestlifer_posts.post_type IN ('post', 'page', 'attachment') AND (COMdigestlifer_posts.post_status = 'publish')) AND post_type != 'revision') AND post_status != 'future';

----------------------------------------------

 


// WP-PageNavi

function custom_wp_pagenavi($before = '', $after = '', $prelabel = '', $nxtlabel = '', $pages_to_show = 12, $always_show = false) {
 global $request, $posts_per_page, $wpdb, $paged;
 if(empty($prelabel)) {
  $prelabel  = '<strong>&laquo;</strong>';
 }
 if(empty($nxtlabel)) {
  $nxtlabel = '<strong>&raquo;</strong>';
 }
 $half_pages_to_show = round($pages_to_show/2);
 if (!is_single()) {
  if(!is_category()) {
   preg_match('#FROM\s(.*)\sORDER BY#siU', $request, $matches);
  } else {
   preg_match('#FROM\s(.*)\sGROUP BY#siU', $request, $matches);
  }
  $fromwhere = $matches[1];
  $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere");
  $max_page = ceil($numposts /$posts_per_page);
  if(empty($paged)) {
   $paged = 1;
  }
  if($max_page > 1 || $always_show) {
   echo "$before <div class=\"wp-pagenavi\"><span class=\"pages\">Page $paged of $max_page:</span>";
   if ($paged >= ($pages_to_show-1)) {
    echo '<a href="'.get_pagenum_link().'">&laquo; First</a>&nbsp;';
   }
   previous_posts_link($prelabel);
   for($i = $paged - $half_pages_to_show; $i  <= $paged + $half_pages_to_show; $i++) {
    if ($i >= 1 && $i <= $max_page) {
     if($i == $paged) {
      echo "<strong class='current'>$i</strong>";
     } else {
      echo ' <a href="'.get_pagenum_link($i).'">'.$i.'</a> ';
     }
    }
   }
   next_posts_link($nxtlabel, $max_page);
   if (($paged+$half_pages_to_show) < ($max_page)) {
    echo '&nbsp;<a href="'.get_pagenum_link($max_page).'">Last &raquo;</a>';
   }
   echo "</div> $after";
  }
 }
}

----------------------------------------------------

  $found_rows = '';
  if ( !$q['no_found_rows'] && !empty($limits) )
   $found_rows = 'SQL_CALC_FOUND_ROWS';
///*
  patched start
  /// FIRST SELECT JUST IDs
  $tmp = " SELECT $distinct $wpdb->posts.id FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits";echo $tmp."\n";
  $tmp_q = $wpdb->get_col($tmp);
  $tmp_ids = implode($tmp_q,',');echo $tmp_ids."\n";
  /// NOW NORMAL SELECT WHERE ID IS IN FIRST QUERY LIST
  $this->request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE $wpdb->posts.id IN ($tmp_ids) $groupby $orderby ";echo $this->request;
  patched over
//*/
/*
  $this->request = $old_request = "SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits";//原来的能力
  //echo $this->request;
  patched over over over.all.
*/

  if ( !$q['suppress_filters'] ) {
   $this->request = apply_filters_ref_array( 'posts_request', array( $this->request, &$this ) );
  }

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值