当前位置: 首页>>代码示例>>PHP>>正文


PHP _wp_mysql_week函数代码示例

本文整理汇总了PHP中_wp_mysql_week函数的典型用法代码示例。如果您正苦于以下问题:PHP _wp_mysql_week函数的具体用法?PHP _wp_mysql_week怎么用?PHP _wp_mysql_week使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了_wp_mysql_week函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: wp_get_archives


//.........这里部分代码省略.........
                $output .= get_archives_link($url, $text, $r['format'], $r['before'], $r['after']);
            }
        }
    } elseif ('yearly' == $r['type']) {
        $query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM {$wpdb->posts} {$join} {$where} GROUP BY YEAR(post_date) ORDER BY post_date {$order} {$limit}";
        $key = md5($query);
        $key = "wp_get_archives:{$key}:{$last_changed}";
        if (!($results = wp_cache_get($key, 'posts'))) {
            $results = $wpdb->get_results($query);
            wp_cache_set($key, $results, 'posts');
        }
        if ($results) {
            $after = $r['after'];
            foreach ((array) $results as $result) {
                $url = get_year_link($result->year);
                $text = sprintf('%d', $result->year);
                if ($r['show_post_count']) {
                    $r['after'] = ' (' . $result->posts . ')' . $after;
                }
                $output .= get_archives_link($url, $text, $r['format'], $r['before'], $r['after']);
            }
        }
    } elseif ('daily' == $r['type']) {
        $query = "SELECT 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 {$order} {$limit}";
        $key = md5($query);
        $key = "wp_get_archives:{$key}:{$last_changed}";
        if (!($results = wp_cache_get($key, 'posts'))) {
            $results = $wpdb->get_results($query);
            wp_cache_set($key, $results, 'posts');
        }
        if ($results) {
            $after = $r['after'];
            foreach ((array) $results as $result) {
                $url = get_day_link($result->year, $result->month, $result->dayofmonth);
                $date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth);
                $text = mysql2date($archive_day_date_format, $date);
                if ($r['show_post_count']) {
                    $r['after'] = ' (' . $result->posts . ')' . $after;
                }
                $output .= get_archives_link($url, $text, $r['format'], $r['before'], $r['after']);
            }
        }
    } elseif ('weekly' == $r['type']) {
        $week = _wp_mysql_week('`post_date`');
        $query = "SELECT DISTINCT {$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}, YEAR( `post_date` ) ORDER BY `post_date` {$order} {$limit}";
        $key = md5($query);
        $key = "wp_get_archives:{$key}:{$last_changed}";
        if (!($results = wp_cache_get($key, 'posts'))) {
            $results = $wpdb->get_results($query);
            wp_cache_set($key, $results, 'posts');
        }
        $arc_w_last = '';
        if ($results) {
            $after = $r['after'];
            foreach ((array) $results as $result) {
                if ($result->week != $arc_w_last) {
                    $arc_year = $result->yr;
                    $arc_w_last = $result->week;
                    $arc_week = get_weekstartend($result->yyyymmdd, get_option('start_of_week'));
                    $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
                    $arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
                    $url = sprintf('%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', home_url(), '', '?', '=', $arc_year, '&', '=', $result->week);
                    $text = $arc_week_start . $archive_week_separator . $arc_week_end;
                    if ($r['show_post_count']) {
                        $r['after'] = ' (' . $result->posts . ')' . $after;
                    }
                    $output .= get_archives_link($url, $text, $r['format'], $r['before'], $r['after']);
                }
            }
        }
    } elseif ('postbypost' == $r['type'] || 'alpha' == $r['type']) {
        $orderby = 'alpha' == $r['type'] ? 'post_title ASC ' : 'post_date DESC, ID DESC ';
        $query = "SELECT * FROM {$wpdb->posts} {$join} {$where} ORDER BY {$orderby} {$limit}";
        $key = md5($query);
        $key = "wp_get_archives:{$key}:{$last_changed}";
        if (!($results = wp_cache_get($key, 'posts'))) {
            $results = $wpdb->get_results($query);
            wp_cache_set($key, $results, 'posts');
        }
        if ($results) {
            foreach ((array) $results as $result) {
                if ($result->post_date != '0000-00-00 00:00:00') {
                    $url = get_permalink($result);
                    if ($result->post_title) {
                        /** This filter is documented in wp-includes/post-template.php */
                        $text = strip_tags(apply_filters('the_title', $result->post_title, $result->ID));
                    } else {
                        $text = $result->ID;
                    }
                    $output .= get_archives_link($url, $text, $r['format'], $r['before'], $r['after']);
                }
            }
        }
    }
    if ($r['echo']) {
        echo $output;
    } else {
        return $output;
    }
}
开发者ID:jenoya,项目名称:final,代码行数:101,代码来源:general-template.php

示例2: get_items

 /**
  * @api
  * @param array|string $args
  * @return array|string
  */
 function get_items($args = null)
 {
     global $wpdb;
     $defaults = array('type' => 'monthly-nested', 'limit' => '', 'show_post_count' => false, 'order' => 'DESC', 'post_type' => 'post', 'show_year' => false, 'nested' => false);
     $args = wp_parse_args($args, $defaults);
     $post_type = $args['post_type'];
     $order = $args['order'];
     $nested = $args['nested'];
     $type = $args['type'];
     $limit = '';
     if ($type == 'yearlymonthly' || $type == 'yearmonth') {
         $type = 'monthly-nested';
     }
     if ($type == 'monthly-nested') {
         $nested = true;
     }
     if (!empty($args['limit'])) {
         $limit = absint($limit);
         $limit = ' LIMIT ' . $limit;
     }
     $order = strtoupper($order);
     if ($order !== 'ASC') {
         $order = 'DESC';
     }
     // this is what will separate dates on weekly archive links
     $archive_week_separator = '–';
     // over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
     $archive_date_format_over_ride = 0;
     // options for daily archive (only if you over-ride the general date format)
     $archive_day_date_format = 'Y/m/d';
     // options for weekly archive (only if you over-ride the general date format)
     $archive_week_start_date_format = 'Y/m/d';
     $archive_week_end_date_format = 'Y/m/d';
     if (!$archive_date_format_over_ride) {
         $archive_day_date_format = get_option('date_format');
         $archive_week_start_date_format = get_option('date_format');
         $archive_week_end_date_format = get_option('date_format');
     }
     $where = $wpdb->prepare('WHERE post_type = "%s" AND post_status = "publish"', $post_type);
     $where = apply_filters('getarchives_where', $where, $args);
     $join = apply_filters('getarchives_join', '', $args);
     $output = array();
     $last_changed = wp_cache_get('last_changed', 'posts');
     if (!$last_changed) {
         $last_changed = microtime();
         wp_cache_set('last_changed', $last_changed, 'posts');
     }
     if ('monthly' == $type) {
         $output = $this->get_items_monthly($args, $last_changed, $join, $where, $order, $limit, $nested);
     } elseif ('yearly' == $type) {
         $output = $this->get_items_yearly($args, $last_changed, $join, $where, $order, $limit);
     } elseif ('monthly-nested' == $type) {
         $years = $this->get_items_yearly($args, $last_changed, $join, $where, $order, $limit);
         foreach ($years as &$year) {
             $args = array('show_year' => false);
             $year['children'] = $this->get_items_monthly($args, $last_changed, $join, $where, $order, $limit);
         }
         $output = $years;
     } elseif ('daily' == $type) {
         $query = "SELECT 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 {$order} {$limit}";
         $key = md5($query);
         $key = "wp_get_archives:{$key}:{$last_changed}";
         if (!($results = wp_cache_get($key, 'posts'))) {
             $results = $wpdb->get_results($query);
             $cache = array();
             $cache[$key] = $results;
             wp_cache_set($key, $results, 'posts');
         }
         if ($results) {
             foreach ((array) $results as $result) {
                 $url = get_day_link($result->year, $result->month, $result->dayofmonth);
                 $date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth);
                 $text = mysql2date($archive_day_date_format, $date);
                 $output[] = $this->get_archives_link($url, $text);
             }
         }
     } elseif ('weekly' == $type) {
         $week = _wp_mysql_week('`post_date`');
         $query = "SELECT DISTINCT {$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}, YEAR( `post_date` ) ORDER BY `post_date` {$order} {$limit}";
         $key = md5($query);
         $key = "wp_get_archives:{$key}:{$last_changed}";
         if (!($results = wp_cache_get($key, 'posts'))) {
             $results = $wpdb->get_results($query);
             wp_cache_set($key, $results, 'posts');
         }
         $arc_w_last = '';
         if ($results) {
             foreach ((array) $results as $result) {
                 if ($result->week != $arc_w_last) {
                     $arc_year = $result->yr;
                     $arc_w_last = $result->week;
                     $arc_week = get_weekstartend($result->yyyymmdd, get_option('start_of_week'));
                     $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
                     $arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
                     $url = sprintf('%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', home_url(), '', '?', '=', $arc_year, '&', '=', $result->week);
//.........这里部分代码省略.........
开发者ID:sdunham,项目名称:sustainable,代码行数:101,代码来源:timber-archives.php

示例3: wp_get_archives


//.........这里部分代码省略.........
        } else {
            $arcresults = $cache[$key];
        }
        if ($arcresults) {
            $afterafter = $after;
            foreach ((array) $arcresults as $arcresult) {
                $url = get_year_link($arcresult->year);
                $text = sprintf('%d', $arcresult->year);
                if ($show_post_count) {
                    $after = ' (' . $arcresult->posts . ')' . $afterafter;
                }
                $output .= get_archives_link($url, $text, $format, $before, $after);
            }
        }
    } elseif ('daily' == $type) {
        $query = "SELECT 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}";
        $key = md5($query);
        $cache = wp_cache_get('wp_get_archives', 'general');
        if (!isset($cache[$key])) {
            $arcresults = $wpdb->get_results($query);
            $cache[$key] = $arcresults;
            wp_cache_set('wp_get_archives', $cache, 'general');
        } else {
            $arcresults = $cache[$key];
        }
        if ($arcresults) {
            $afterafter = $after;
            foreach ((array) $arcresults as $arcresult) {
                $url = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth);
                $date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
                $text = mysql2date($archive_day_date_format, $date);
                if ($show_post_count) {
                    $after = ' (' . $arcresult->posts . ')' . $afterafter;
                }
                $output .= get_archives_link($url, $text, $format, $before, $after);
            }
        }
    } elseif ('weekly' == $type) {
        $week = _wp_mysql_week('`post_date`');
        $query = "SELECT DISTINCT {$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}, YEAR( `post_date` ) ORDER BY `post_date` DESC {$limit}";
        $key = md5($query);
        $cache = wp_cache_get('wp_get_archives', 'general');
        if (!isset($cache[$key])) {
            $arcresults = $wpdb->get_results($query);
            $cache[$key] = $arcresults;
            wp_cache_set('wp_get_archives', $cache, 'general');
        } else {
            $arcresults = $cache[$key];
        }
        $arc_w_last = '';
        $afterafter = $after;
        if ($arcresults) {
            foreach ((array) $arcresults as $arcresult) {
                if ($arcresult->week != $arc_w_last) {
                    $arc_year = $arcresult->yr;
                    $arc_w_last = $arcresult->week;
                    $arc_week = get_weekstartend($arcresult->yyyymmdd, get_option('start_of_week'));
                    $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
                    $arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
                    $url = sprintf('%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', home_url(), '', '?', '=', $arc_year, '&', '=', $arcresult->week);
                    $text = $arc_week_start . $archive_week_separator . $arc_week_end;
                    if ($show_post_count) {
                        $after = ' (' . $arcresult->posts . ')' . $afterafter;
                    }
                    $output .= get_archives_link($url, $text, $format, $before, $after);
                }
            }
        }
    } elseif ('postbypost' == $type || 'alpha' == $type) {
        $orderby = 'alpha' == $type ? 'post_title ASC ' : 'post_date DESC ';
        $query = "SELECT * FROM {$wpdb->posts} {$join} {$where} ORDER BY {$orderby} {$limit}";
        $key = md5($query);
        $cache = wp_cache_get('wp_get_archives', 'general');
        if (!isset($cache[$key])) {
            $arcresults = $wpdb->get_results($query);
            $cache[$key] = $arcresults;
            wp_cache_set('wp_get_archives', $cache, 'general');
        } else {
            $arcresults = $cache[$key];
        }
        if ($arcresults) {
            foreach ((array) $arcresults as $arcresult) {
                if ($arcresult->post_date != '0000-00-00 00:00:00') {
                    $url = get_permalink($arcresult);
                    if ($arcresult->post_title) {
                        $text = strip_tags(apply_filters('the_title', $arcresult->post_title, $arcresult->ID));
                    } else {
                        $text = $arcresult->ID;
                    }
                    $output .= get_archives_link($url, $text, $format, $before, $after);
                }
            }
        }
    }
    if ($echo) {
        echo $output;
    } else {
        return $output;
    }
}
开发者ID:batruji,项目名称:metareading,代码行数:101,代码来源:general-template.php

示例4: do_action_ref_array


//.........这里部分代码省略.........
                     if ($reqpage) {
                         break;
                     }
                 }
                 unset($ptype_obj);
             } else {
                 $reqpage = get_page_by_path($q['pagename']);
             }
             if (!empty($reqpage)) {
                 $reqpage = $reqpage->ID;
             } else {
                 $reqpage = 0;
             }
         }
         $page_for_posts = get_option('page_for_posts');
         if ('page' != get_option('show_on_front') || empty($page_for_posts) || $reqpage != $page_for_posts) {
             $q['pagename'] = sanitize_title_for_query(wp_basename($q['pagename']));
             $q['name'] = $q['pagename'];
             $where .= " AND ({$wpdb->posts}.ID = '{$reqpage}')";
             $reqpage_obj = get_page($reqpage);
             if (is_object($reqpage_obj) && 'attachment' == $reqpage_obj->post_type) {
                 $this->is_attachment = true;
                 $post_type = $q['post_type'] = 'attachment';
                 $this->is_page = true;
                 $q['attachment_id'] = $reqpage;
             }
         }
     } elseif ('' != $q['attachment']) {
         $q['attachment'] = sanitize_title_for_query(wp_basename($q['attachment']));
         $q['name'] = $q['attachment'];
         $where .= " AND {$wpdb->posts}.post_name = '" . $q['attachment'] . "'";
     }
     if ($q['w']) {
         $where .= ' AND ' . _wp_mysql_week("`{$wpdb->posts}`.`post_date`") . " = '" . $q['w'] . "'";
     }
     if (intval($q['comments_popup'])) {
         $q['p'] = absint($q['comments_popup']);
     }
     // If an attachment is requested by number, let it supersede any post number.
     if ($q['attachment_id']) {
         $q['p'] = absint($q['attachment_id']);
     }
     // If a post number is specified, load that post
     if ($q['p']) {
         $where .= " AND {$wpdb->posts}.ID = " . $q['p'];
     } elseif ($q['post__in']) {
         $post__in = implode(',', array_map('absint', $q['post__in']));
         $where .= " AND {$wpdb->posts}.ID IN ({$post__in})";
     } elseif ($q['post__not_in']) {
         $post__not_in = implode(',', array_map('absint', $q['post__not_in']));
         $where .= " AND {$wpdb->posts}.ID NOT IN ({$post__not_in})";
     }
     if (is_numeric($q['post_parent'])) {
         $where .= $wpdb->prepare(" AND {$wpdb->posts}.post_parent = %d ", $q['post_parent']);
     }
     if ($q['page_id']) {
         if ('page' != get_option('show_on_front') || $q['page_id'] != get_option('page_for_posts')) {
             $q['p'] = $q['page_id'];
             $where = " AND {$wpdb->posts}.ID = " . $q['page_id'];
         }
     }
     // If a search pattern is specified, load the posts that match
     if (!empty($q['s'])) {
         // added slashes screw with quote grouping when done early, so done later
         $q['s'] = stripslashes($q['s']);
         if (!empty($q['sentence'])) {
开发者ID:nunomorgadinho,项目名称:WordPress,代码行数:67,代码来源:query.php

示例5: get_sql_for_clause

 /**
  * Turns a first-order date query into SQL for a WHERE clause.
  *
  * @since  4.1.0
  * @access protected
  *
  * @param  array $query        Date query clause.
  * @param  array $parent_query Parent query of the current date query.
  * @return array {
  *     Array containing JOIN and WHERE SQL clauses to append to the main query.
  *
  *     @type string $join  SQL fragment to append to the main JOIN clause.
  *     @type string $where SQL fragment to append to the main WHERE clause.
  * }
  */
 protected function get_sql_for_clause($query, $parent_query)
 {
     global $wpdb;
     // The sub-parts of a $where part.
     $where_parts = array();
     $column = !empty($query['column']) ? esc_sql($query['column']) : $this->column;
     $column = $this->validate_column($column);
     $compare = $this->get_compare($query);
     $inclusive = !empty($query['inclusive']);
     // Assign greater- and less-than values.
     $lt = '<';
     $gt = '>';
     if ($inclusive) {
         $lt .= '=';
         $gt .= '=';
     }
     // Range queries.
     if (!empty($query['after'])) {
         $where_parts[] = $wpdb->prepare("{$column} {$gt} %s", $this->build_mysql_datetime($query['after'], !$inclusive));
     }
     if (!empty($query['before'])) {
         $where_parts[] = $wpdb->prepare("{$column} {$lt} %s", $this->build_mysql_datetime($query['before'], $inclusive));
     }
     // Specific value queries.
     if (isset($query['year']) && ($value = $this->build_value($compare, $query['year']))) {
         $where_parts[] = "YEAR( {$column} ) {$compare} {$value}";
     }
     if (isset($query['month']) && ($value = $this->build_value($compare, $query['month']))) {
         $where_parts[] = "MONTH( {$column} ) {$compare} {$value}";
     } elseif (isset($query['monthnum']) && ($value = $this->build_value($compare, $query['monthnum']))) {
         $where_parts[] = "MONTH( {$column} ) {$compare} {$value}";
     }
     if (isset($query['week']) && false !== ($value = $this->build_value($compare, $query['week']))) {
         $where_parts[] = _wp_mysql_week($column) . " {$compare} {$value}";
     } elseif (isset($query['w']) && false !== ($value = $this->build_value($compare, $query['w']))) {
         $where_parts[] = _wp_mysql_week($column) . " {$compare} {$value}";
     }
     if (isset($query['dayofyear']) && ($value = $this->build_value($compare, $query['dayofyear']))) {
         $where_parts[] = "DAYOFYEAR( {$column} ) {$compare} {$value}";
     }
     if (isset($query['day']) && ($value = $this->build_value($compare, $query['day']))) {
         $where_parts[] = "DAYOFMONTH( {$column} ) {$compare} {$value}";
     }
     if (isset($query['dayofweek']) && ($value = $this->build_value($compare, $query['dayofweek']))) {
         $where_parts[] = "DAYOFWEEK( {$column} ) {$compare} {$value}";
     }
     if (isset($query['dayofweek_iso']) && ($value = $this->build_value($compare, $query['dayofweek_iso']))) {
         $where_parts[] = "WEEKDAY( {$column} ) + 1 {$compare} {$value}";
     }
     if (isset($query['hour']) || isset($query['minute']) || isset($query['second'])) {
         // Avoid notices.
         foreach (array('hour', 'minute', 'second') as $unit) {
             if (!isset($query[$unit])) {
                 $query[$unit] = null;
             }
         }
         if ($time_query = $this->build_time_query($column, $compare, $query['hour'], $query['minute'], $query['second'])) {
             $where_parts[] = $time_query;
         }
     }
     /*
      * Return an array of 'join' and 'where' for compatibility
      * with other query classes.
      */
     return array('where' => $where_parts, 'join' => array());
 }
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:81,代码来源:date.php

示例6: get_sql_for_subquery

 /**
  * Turns a single date subquery into pieces for a WHERE clause.
  *
  * @since 3.7.0
  * return array
  */
 protected function get_sql_for_subquery($query)
 {
     global $wpdb;
     // The sub-parts of a $where part
     $where_parts = array();
     $column = !empty($query['column']) ? esc_sql($query['column']) : $this->column;
     $column = $this->validate_column($column);
     $compare = $this->get_compare($query);
     $lt = '<';
     $gt = '>';
     if (!empty($query['inclusive'])) {
         $lt .= '=';
         $gt .= '=';
     }
     // Range queries
     if (!empty($query['after'])) {
         $where_parts[] = $wpdb->prepare("{$column} {$gt} %s", $this->build_mysql_datetime($query['after'], true));
     }
     if (!empty($query['before'])) {
         $where_parts[] = $wpdb->prepare("{$column} {$lt} %s", $this->build_mysql_datetime($query['before'], false));
     }
     // Specific value queries
     if (isset($query['year']) && ($value = $this->build_value($compare, $query['year']))) {
         $where_parts[] = "YEAR( {$column} ) {$compare} {$value}";
     }
     if (isset($query['month']) && ($value = $this->build_value($compare, $query['month']))) {
         $where_parts[] = "MONTH( {$column} ) {$compare} {$value}";
     }
     // Legacy
     if (isset($query['monthnum']) && ($value = $this->build_value($compare, $query['monthnum']))) {
         $where_parts[] = "MONTH( {$column} ) {$compare} {$value}";
     }
     if (isset($query['week']) && false !== ($value = $this->build_value($compare, $query['week']))) {
         $where_parts[] = _wp_mysql_week($column) . " {$compare} {$value}";
     }
     // Legacy
     if (isset($query['w']) && false !== ($value = $this->build_value($compare, $query['w']))) {
         $where_parts[] = _wp_mysql_week($column) . " {$compare} {$value}";
     }
     if (isset($query['dayofyear']) && ($value = $this->build_value($compare, $query['dayofyear']))) {
         $where_parts[] = "DAYOFYEAR( {$column} ) {$compare} {$value}";
     }
     if (isset($query['day']) && ($value = $this->build_value($compare, $query['day']))) {
         $where_parts[] = "DAYOFMONTH( {$column} ) {$compare} {$value}";
     }
     if (isset($query['dayofweek']) && ($value = $this->build_value($compare, $query['dayofweek']))) {
         $where_parts[] = "DAYOFWEEK( {$column} ) {$compare} {$value}";
     }
     if (isset($query['hour']) || isset($query['minute']) || isset($query['second'])) {
         // Avoid notices
         foreach (array('hour', 'minute', 'second') as $unit) {
             if (!isset($query[$unit])) {
                 $query[$unit] = null;
             }
         }
         if ($time_query = $this->build_time_query($column, $compare, $query['hour'], $query['minute'], $query['second'])) {
             $where_parts[] = $time_query;
         }
     }
     return $where_parts;
 }
开发者ID:dev-lav,项目名称:htdocs,代码行数:67,代码来源:date.php

示例7: do_action_ref_array


//.........这里部分代码省略.........
                 unset($ptype_obj);
             } else {
                 $reqpage = get_page_by_path($q['pagename']);
             }
             if (!empty($reqpage)) {
                 $reqpage = $reqpage->ID;
             } else {
                 $reqpage = 0;
             }
         }
         $page_for_posts = get_option('page_for_posts');
         if ('page' != get_option('show_on_front') || empty($page_for_posts) || $reqpage != $page_for_posts) {
             $q['pagename'] = str_replace('%2F', '/', urlencode(urldecode($q['pagename'])));
             $page_paths = '/' . trim($q['pagename'], '/');
             $q['pagename'] = sanitize_title(basename($page_paths));
             $q['name'] = $q['pagename'];
             $where .= " AND ({$wpdb->posts}.ID = '{$reqpage}')";
             $reqpage_obj = get_page($reqpage);
             if (is_object($reqpage_obj) && 'attachment' == $reqpage_obj->post_type) {
                 $this->is_attachment = true;
                 $post_type = $q['post_type'] = 'attachment';
                 $this->is_page = true;
                 $q['attachment_id'] = $reqpage;
             }
         }
     } elseif ('' != $q['attachment']) {
         $q['attachment'] = str_replace('%2F', '/', urlencode(urldecode($q['attachment'])));
         $attach_paths = '/' . trim($q['attachment'], '/');
         $q['attachment'] = sanitize_title(basename($attach_paths));
         $q['name'] = $q['attachment'];
         $where .= " AND {$wpdb->posts}.post_name = '" . $q['attachment'] . "'";
     }
     if ($q['w']) {
         $where .= ' AND ' . _wp_mysql_week("`{$wpdb->posts}`.`post_date`") . " = '" . $q['w'] . "'";
     }
     if (intval($q['comments_popup'])) {
         $q['p'] = absint($q['comments_popup']);
     }
     // If an attachment is requested by number, let it supercede any post number.
     if ($q['attachment_id']) {
         $q['p'] = absint($q['attachment_id']);
     }
     // If a post number is specified, load that post
     if ($q['p']) {
         $where .= " AND {$wpdb->posts}.ID = " . $q['p'];
     } elseif ($q['post__in']) {
         $post__in = implode(',', array_map('absint', $q['post__in']));
         $where .= " AND {$wpdb->posts}.ID IN ({$post__in})";
     } elseif ($q['post__not_in']) {
         $post__not_in = implode(',', array_map('absint', $q['post__not_in']));
         $where .= " AND {$wpdb->posts}.ID NOT IN ({$post__not_in})";
     }
     if (is_numeric($q['post_parent'])) {
         $where .= $wpdb->prepare(" AND {$wpdb->posts}.post_parent = %d ", $q['post_parent']);
     }
     if ($q['page_id']) {
         if ('page' != get_option('show_on_front') || $q['page_id'] != get_option('page_for_posts')) {
             $q['p'] = $q['page_id'];
             $where = " AND {$wpdb->posts}.ID = " . $q['page_id'];
         }
     }
     // If a search pattern is specified, load the posts that match
     if (!empty($q['s'])) {
         // added slashes screw with quote grouping when done early, so done later
         $q['s'] = stripslashes($q['s']);
         if (!empty($q['sentence'])) {
开发者ID:owaismeo,项目名称:wordpress-10,代码行数:67,代码来源:query.php

示例8: get_gmedias


//.........这里部分代码省略.........
         if (strlen($q['m']) > 9) {
             $where .= " AND HOUR({$wpdb->prefix}gmedia.date)=" . substr($q['m'], 8, 2);
         }
         if (strlen($q['m']) > 11) {
             $where .= " AND MINUTE({$wpdb->prefix}gmedia.date)=" . substr($q['m'], 10, 2);
         }
         if (strlen($q['m']) > 13) {
             $where .= " AND SECOND({$wpdb->prefix}gmedia.date)=" . substr($q['m'], 12, 2);
         }
     }
     if ('' !== $q['hour']) {
         $where .= " AND HOUR({$wpdb->prefix}gmedia.date)='" . $q['hour'] . "'";
     }
     if ('' !== $q['minute']) {
         $where .= " AND MINUTE({$wpdb->prefix}gmedia.date)='" . $q['minute'] . "'";
     }
     if ('' !== $q['second']) {
         $where .= " AND SECOND({$wpdb->prefix}gmedia.date)='" . $q['second'] . "'";
     }
     if ($q['year']) {
         $where .= " AND YEAR({$wpdb->prefix}gmedia.date)='" . $q['year'] . "'";
     }
     if ($q['monthnum']) {
         $where .= " AND MONTH({$wpdb->prefix}gmedia.date)='" . $q['monthnum'] . "'";
     }
     if ($q['day']) {
         $where .= " AND DAYOFMONTH({$wpdb->prefix}gmedia.date)='" . $q['day'] . "'";
     }
     if ('' != $q['name']) {
         $q['name'] = esc_sql($q['name']);
         $where .= " AND {$wpdb->prefix}gmedia.title = '" . $q['name'] . "'";
     }
     if ($q['w']) {
         $where .= ' AND ' . _wp_mysql_week("`{$wpdb->prefix}gmedia`.`date`") . " = '" . $q['w'] . "'";
     }
     // If a gmedia number is specified, load that gmedia
     if ($q['gmedia_id']) {
         $where .= " AND {$wpdb->prefix}gmedia.ID = " . $q['gmedia_id'];
     } elseif ($q['gmedia__in']) {
         if (!is_array($q['gmedia__in'])) {
             $q['gmedia__in'] = explode(',', $q['gmedia__in']);
         }
         $gmedia__in = implode(',', array_filter(array_map('absint', $q['gmedia__in'])));
         $where .= " AND {$wpdb->prefix}gmedia.ID IN ({$gmedia__in})";
     } elseif ($q['gmedia__not_in']) {
         if (!is_array($q['gmedia__not_in'])) {
             $q['gmedia__not_in'] = explode(',', $q['gmedia__not_in']);
         }
         $gmedia__not_in = implode(',', array_filter(array_map('absint', $q['gmedia__not_in'])));
         $where .= " AND {$wpdb->prefix}gmedia.ID NOT IN ({$gmedia__not_in})";
     }
     // If a search pattern is specified, load the posts that match
     if (!empty($q['s'])) {
         // added slashes screw with quote grouping when done early, so done later
         $q['s'] = stripslashes($q['s']);
         if (empty($q['exact'])) {
             $q['search_terms'] = array_filter(array_map('trim', explode(' ', $q['s'])));
         } else {
             $q['search_terms'] = $q['s'];
         }
         $n = '%';
         $searchand = '';
         foreach ((array) $q['search_terms'] as $term) {
             $term = esc_sql(addcslashes($term, '_%\\'));
             $search .= "{$searchand}(({$wpdb->prefix}gmedia.title LIKE '{$n}{$term}{$n}') OR ({$wpdb->prefix}gmedia.description LIKE '{$n}{$term}{$n}') OR ({$wpdb->prefix}gmedia.gmuid LIKE '{$n}{$term}{$n}'))";
             $searchand = ' AND ';
开发者ID:HugoLS,项目名称:Variation,代码行数:67,代码来源:db.connect.php


注:本文中的_wp_mysql_week函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。