public function getSQL(\Parm\DataAccessObjectFactory $factory) { if ($this->value === null) { return $this->field . " " . $this->operator . " NULL"; } elseif ($this->value instanceof \DateTime) { return $this->field . " " . $this->operator . " " . $factory->escapeString($this->value->format($factory->getDatetimeStorageFormat())); } elseif (is_numeric($this->value)) { $date = new \DateTime(); $date->setTimestamp((int) $this->value); return $this->field . " " . $this->operator . " " . $factory->escapeString($date->format($factory->getDatetimeStorageFormat())); } else { return $this->field . " " . $this->operator . " " . $factory->escapeString((string) $this->value); } }
/** * @param $columnName * @param null $format * @return mixed|string * @throws GetFieldValueException */ protected function getDatetimeFieldValue($columnName, $format = null) { if ($format != null && $this->getFieldValue($columnName) != null) { $dateTime = \DateTime::createFromFormat($this->factory->getDatetimeStorageFormat(), $this->getFieldValue($columnName)); if ($dateTime) { // $dateTime will be a new DateTime instance or FALSE on failure. return $dateTime->format($format); } } return $this->getFieldValue($columnName); }