Changeset 6296 for trunk/wp-includes/general-template.php
- Timestamp:
- 10/30/2007 06:03:11 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/general-template.php
r6195 r6296 395 395 396 396 if ( 'monthly' == $type ) { 397 $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit); 397 $query = "SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC $limit"; 398 $key = md5($query); 399 $cache = wp_cache_get( 'wp_get_archives' , 'general'); 400 if ( !isset( $cache[ $key ] ) ) { 401 $arcresults = $wpdb->get_results($query); 402 $cache[ $key ] = $arcresults; 403 wp_cache_add( 'wp_get_archives', $cache, 'general' ); 404 } else { 405 $arcresults = $cache[ $key ]; 406 } 398 407 if ( $arcresults ) { 399 408 $afterafter = $after; … … 407 416 } 408 417 } elseif ('yearly' == $type) { 409 $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date DESC" . $limit); 418 $query = "SELECT DISTINCT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date DESC $limit"; 419 $key = md5($query); 420 $cache = wp_cache_get( 'wp_get_archives' , 'general'); 421 if ( !isset( $cache[ $key ] ) ) { 422 $arcresults = $wpdb->get_results($query); 423 $cache[ $key ] = $arcresults; 424 wp_cache_add( 'wp_get_archives', $cache, 'general' ); 425 } else { 426 $arcresults = $cache[ $key ]; 427 } 410 428 if ($arcresults) { 411 429 $afterafter = $after; … … 419 437 } 420 438 } elseif ( 'daily' == $type ) { 421 $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date DESC" . $limit); 439 $query = "SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date DESC $limit"; 440 $key = md5($query); 441 $cache = wp_cache_get( 'wp_get_archives' , 'general'); 442 if ( !isset( $cache[ $key ] ) ) { 443 $arcresults = $wpdb->get_results($query); 444 $cache[ $key ] = $arcresults; 445 wp_cache_add( 'wp_get_archives', $cache, 'general' ); 446 } else { 447 $arcresults = $cache[ $key ]; 448 } 422 449 if ( $arcresults ) { 423 450 $afterafter = $after; … … 433 460 } elseif ( 'weekly' == $type ) { 434 461 $start_of_week = get_option('start_of_week'); 435 $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY WEEK(post_date, $start_of_week), YEAR(post_date) ORDER BY post_date DESC" . $limit); 462 $query = "SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY WEEK(post_date, $start_of_week), YEAR(post_date) ORDER BY post_date DESC $limit"; 463 $key = md5($query); 464 $cache = wp_cache_get( 'wp_get_archives' , 'general'); 465 if ( !isset( $cache[ $key ] ) ) { 466 $arcresults = $wpdb->get_results($query); 467 $cache[ $key ] = $arcresults; 468 wp_cache_add( 'wp_get_archives', $cache, 'general' ); 469 } else { 470 $arcresults = $cache[ $key ]; 471 } 436 472 $arc_w_last = ''; 437 473 $afterafter = $after; … … 454 490 } elseif ( ( 'postbypost' == $type ) || ('alpha' == $type) ) { 455 491 ('alpha' == $type) ? $orderby = "post_title ASC " : $orderby = "post_date DESC "; 456 $arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit"); 492 $query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit"; 493 $key = md5($query); 494 $cache = wp_cache_get( 'wp_get_archives' , 'general'); 495 if ( !isset( $cache[ $key ] ) ) { 496 $arcresults = $wpdb->get_results($query); 497 $cache[ $key ] = $arcresults; 498 wp_cache_add( 'wp_get_archives', $cache, 'general' ); 499 } else { 500 $arcresults = $cache[ $key ]; 501 } 457 502 if ( $arcresults ) { 458 503 foreach ( $arcresults as $arcresult ) {
Note: See TracChangeset
for help on using the changeset viewer.