function views_date_format_sql_handler_date_field::query in Views Date Format SQL 7.3
Called to add the field to a query.
By default, the only columns added to the query are entity_id and entity_type. This is because other needed data is fetched by entity_load(). Other columns are added only if they are used in groupings, or if 'add fields to query' is specifically set to TRUE in the field definition.
The 'add fields to query' switch is used by modules which need all data present in the query itself (such as "sphinx").
Overrides views_handler_field_field::query
File
- includes/
views_date_format_sql_handler_date_field.inc, line 31 - This file contains the class to override views_handler_field_date.
Class
- views_date_format_sql_handler_date_field
- Allows to removes the date formatting from render() and put it in query().
Code
function query($use_groupby = FALSE) {
parent::query($use_groupby);
if ($this->options['format_date_sql'] != TRUE) {
return;
}
$format_type = isset($this->options['settings']['format_type']) ? $this->options['settings']['format_type'] : '';
$format_string = isset($this->options['settings']['custom_date_format']) ? $this->options['settings']['custom_date_format'] : '';
$format_string = _views_date_format_sql_get_date_format($format_type, $format_string);
$field_type = $this->field_info['type'] == 'datestamp' ? 'int' : $this->field_info['type'];
// If this is a date module filed we have to get the storage field type.
$formula = views_date_sql_format($format_string, "{$this->table_alias}.{$this->real_field}", $field_type, 0);
$this->query->fields[$this->aliases[$this->real_field]]['field'] = $formula;
$this->query->fields[$this->aliases[$this->real_field]]['table'] = NULL;
}