[ Index ]

WordPress Cross Reference

title

Body

[close]

/wp-includes/ -> date.php (summary)

(no description)

File Size: 449 lines (17 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

WP_Date_Query:: (8 methods):
  __construct()
  get_compare()
  validate_column()
  get_sql()
  get_sql_for_subquery()
  build_value()
  build_mysql_datetime()
  build_time_query()


Class: WP_Date_Query  - X-Ref

WP_Date_Query will generate a MySQL WHERE clause for the specified date-based parameters.

Initialize the class by passing an array of arrays of parameters.

__construct( $date_query, $default_column = 'post_date' )   X-Ref
Constructor.

param: array $date_query {
param: array $default_column Optional. Default column to query against. Default 'post_date'.

get_compare( $query )   X-Ref
Determines and validates what comparison operator to use.

param: array $query A date query or a date subquery
return: string The comparison operator

validate_column( $column )   X-Ref
Validates a column name parameter.

param: string $column The user-supplied column name.
return: string A validated column name value.

get_sql()   X-Ref
Turns an array of date query parameters into a MySQL string.

return: string MySQL WHERE parameters

get_sql_for_subquery( $query )   X-Ref
Turns a single date subquery into pieces for a WHERE clause.


build_value( $compare, $value )   X-Ref
Builds and validates a value string based on the comparison operator.

param: string $compare The compare operator to use
param: string|array $value The value
return: string|int|false The value to be used in SQL or false on error.

build_mysql_datetime( $datetime, $default_to_max = false )   X-Ref
Builds a MySQL format date/time based on some query parameters.

You can pass an array of values (year, month, etc.) with missing parameter values being defaulted to
either the maximum or minimum values (controlled by the $default_to parameter). Alternatively you can
pass a string that that will be run through strtotime().

param: string|array $datetime An array of parameters or a strotime() string
param: string $default_to Controls what values default to if they are missing from $datetime. Pass "min" or "max".
return: string|false A MySQL format date/time or false on failure

build_time_query( $column, $compare, $hour = null, $minute = null, $second = null )   X-Ref
Builds a query string for comparing time values (hour, minute, second).

If just hour, minute, or second is set than a normal comparison will be done.
However if multiple values are passed, a pseudo-decimal time will be created
in order to be able to accurately compare against.

param: string $column The column to query against. Needs to be pre-validated!
param: string $compare The comparison operator. Needs to be pre-validated!
param: int|null $hour Optional. An hour value (0-23).
param: int|null $minute Optional. A minute value (0-59).
param: int|null $second Optional. A second value (0-59).
return: string|false A query part or false on failure.



Generated: Tue Mar 25 01:41:18 2014 WordPress honlapkészítés: online1.hu