You are here

function DateSqlHandler::sql_where_format in Date 8

Create a where clause to compare a formated field to a formated value.

Parameters

string $format: The format to use on the date and the value when comparing them.

string $field: The db table and field name, like "$table.$field".

string $operator: The db comparison operator to use, like '=' .

string $value: The value to compare the extracted date part to, could be a field name or a date string or NOW().

Return value

string SQL for the where clause for this operation.

File

date_api/lib/Drupal/date_api/DateSqlHandler.php, line 605

Class

DateSqlHandler
A class to manipulate date SQL.

Namespace

Drupal\date_api

Code

function sql_where_format($format, $field, $operator, $value, $adjustment = NULL) {
  if (empty($adjustment) && $this->local_timezone != $this->db_timezone) {
    $field = $this
      ->sql_field($field);
  }
  else {
    $field = $this
      ->sql_field($field, $adjustment);
  }
  return $this
    ->sql_format($format, $field) . " {$operator} '{$value}'";
}