Called to add the sort to a query.
Overrides SortPluginBase::query
public function query() {
$this
->ensureMyTable();
switch ($this->options['granularity']) {
case 'second':
default:
$this->query
->add_orderby($this->tableAlias, $this->realField, $this->options['order']);
return;
case 'minute':
$formula = $this
->getSQLFormat('YmdHi');
break;
case 'hour':
$formula = $this
->getSQLFormat('YmdH');
break;
case 'day':
$formula = $this
->getSQLFormat('Ymd');
break;
case 'month':
$formula = $this
->getSQLFormat('Ym');
break;
case 'year':
$formula = $this
->getSQLFormat('Y');
break;
}
// Add the field.
$this->query
->add_orderby(NULL, $formula, $this->options['order'], $this->tableAlias . '_' . $this->field . '_' . $this->options['granularity']);
}