Returns the SQL that adds an interval to a timestamp value.

@param string $column
@param numeric $expr
@param string $type one of SECOND, MINUTE, HOUR, DAY, MONTH, or YEAR
@return string
183219
public function dateAdd( $column, $expr, $type )
    {
        $type = $this->intervalMap[$type];
        $column = $this->getIdentifier( $column );

        if ( $column != 'NOW()' )
        {
            $column = "CAST( {$column} AS TIMESTAMP )";
        }

        return " {$column} + INTERVAL '{$expr}' {$type} ";
    }
1256512
public function bindColumn($column, &$param, $type = null)
    {
        if ($type === null) :
            $this->_statement->bindColumn($column, $param);
        else :
            $this->_statement->bindColumn($column, $param, $type);
        endif;
    }
5610
protected function runQueryWithExpression(String $expresison, int $type=1)
	{
		$query = $this->builder()->query($expresison, $type);
		Scheme::destroyColumns();
		return $query;
	}
261741
protected function evalTimesinceTypeValue($record, $column, $value)
    {
        if ($value === null) {
            return null;
        }

        $dateTime = $this->validateDateTimeValue($value, $column);

        $value = DateTimeHelper::timeSince($dateTime);

        $options = [
            'defaultValue' => $value,
            'timeSince' => true
        ];

        if (!empty($column->config['ignoreTimezone'])) {
            $options['ignoreTimezone'] = true;
        }

        return Backend::dateTime($dateTime, $options);
    }
746520
public Timestamp getInternalTimestamp(ColumnInformation columnInfo, Calendar userCalendar,
      TimeZone timeZone) throws SQLException {
    if (lastValueWasNull()) {
      return null;
    }

    switch (columnInfo.getColumnType()) {
      case TIMESTAMP:
      case DATETIME:
      case DATE:
      case VARCHAR:
      case VARSTRING:
      case STRING:

        int nanoBegin = -1;
        int[] timestampsPart = new int[]{0,0,0,0,0,0,0};
        int partIdx = 0;
        for (int begin = pos; begin < pos + length; begin++) {
          byte b = buf[begin];
          if (b == '-' || b == ' ' || b == ':') {
            partIdx++;
            continue;
          }
          if (b == '.') {
            partIdx++;
            nanoBegin = begin;
            continue;
          }
          if (b < '0' || b > '9') {
            throw new SQLException(
                "cannot parse data in timestamp string '" + new String(buf, pos, length, StandardCharsets.UTF_8) + "'");
          }

          timestampsPart[partIdx] = timestampsPart[partIdx] * 10 + b - 48;
        }
        if (timestampsPart[0] == 0
            && timestampsPart[1] == 0
            && timestampsPart[2] == 0
            && timestampsPart[3] == 0
            && timestampsPart[4] == 0
            && timestampsPart[5] == 0
            && timestampsPart[6] == 0) {
          lastValueNull |= BIT_LAST_ZERO_DATE;
          return null;
        }

        //fix non leading tray for nanoseconds
        if (nanoBegin > 0) {
          for (int begin = 0; begin < 6 - (pos + length - nanoBegin - 1); begin++) {
            timestampsPart[6] = timestampsPart[6] * 10;
          }
        }

        Timestamp timestamp;

        Calendar calendar;
        if (userCalendar != null) {
          calendar = userCalendar;
        } else if (columnInfo.getColumnType().getSqlType() == Types.TIMESTAMP) {
          calendar = Calendar.getInstance(timeZone);
        } else {
          calendar = Calendar.getInstance();
        }

        synchronized (calendar) {
          calendar.clear();
          calendar.set(Calendar.YEAR, timestampsPart[0]);
          calendar.set(Calendar.MONTH, timestampsPart[1] - 1);
          calendar.set(Calendar.DAY_OF_MONTH, timestampsPart[2]);
          calendar.set(Calendar.HOUR_OF_DAY, timestampsPart[3]);
          calendar.set(Calendar.MINUTE, timestampsPart[4]);
          calendar.set(Calendar.SECOND, timestampsPart[5]);
          calendar.set(Calendar.MILLISECOND, timestampsPart[6] / 1000000);
          timestamp = new Timestamp(calendar.getTime().getTime());
        }
        timestamp.setNanos(timestampsPart[6] * 1000);
        return timestamp;

      case TIME:
        //time does not go after millisecond
        String rawValue = new String(buf, pos, length, StandardCharsets.UTF_8);
        Timestamp tt = new Timestamp(getInternalTime(columnInfo, userCalendar, timeZone).getTime());
        tt.setNanos(extractNanos(rawValue));
        return tt;


      default:
        String value = new String(buf, pos, length, StandardCharsets.UTF_8);
        throw new SQLException("Value type \"" + columnInfo.getColumnType().getTypeName()
            + "\" with value \"" + value + "\" cannot be parse as Timestamp");
    }
  }
452153
public function set(string $column, Expr $expression)
    {
        $this->columnSetMap[$column] = $expression;

        return $this;
    }
1337485
public LocalTime getInternalLocalTime(ColumnInformation columnInfo, TimeZone timeZone)
      throws SQLException {
    if (lastValueWasNull()) {
      return null;
    }
    if (length == 0) {
      lastValueNull |= BIT_LAST_FIELD_NULL;
      return null;
    }

    switch (columnInfo.getColumnType().getSqlType()) {
      case Types.TIME:

        int day = 0;
        int hour = 0;
        int minutes = 0;
        int seconds = 0;
        int microseconds = 0;

        final boolean negate = (buf[pos] & 0xff) == 0x01;

        if (length > 4) {
          day = ((buf[pos + 1] & 0xff)
              + ((buf[pos + 2] & 0xff) << 8)
              + ((buf[pos + 3] & 0xff) << 16)
              + ((buf[pos + 4] & 0xff) << 24));
        }

        if (length > 7) {
          hour = buf[pos + 5];
          minutes = buf[pos + 6];
          seconds = buf[pos + 7];
        }

        if (length > 8) {
          microseconds = ((buf[pos + 8] & 0xff)
              + ((buf[pos + 9] & 0xff) << 8)
              + ((buf[pos + 10] & 0xff) << 16)
              + ((buf[pos + 11] & 0xff) << 24));
        }

        return LocalTime
            .of((negate ? -1 : 1) * (day * 24 + hour), minutes, seconds, microseconds * 1000);

      case Types.VARCHAR:
      case Types.LONGVARCHAR:
      case Types.CHAR:
        //string conversion
        String raw = new String(buf, pos, length, StandardCharsets.UTF_8);
        try {
          return LocalTime
              .parse(raw, DateTimeFormatter.ISO_LOCAL_TIME.withZone(timeZone.toZoneId()));
        } catch (DateTimeParseException dateParserEx) {
          throw new SQLException(
              raw + " cannot be parse as LocalTime (format is \"HH:mm:ss[.S]\" for data type \""
                  + columnInfo.getColumnType() + "\")");
        }

      case Types.TIMESTAMP:
        ZonedDateTime zonedDateTime = getInternalZonedDateTime(columnInfo, LocalTime.class,
            timeZone);
        return zonedDateTime == null ? null
            : zonedDateTime.withZoneSameInstant(ZoneId.systemDefault()).toLocalTime();

      default:
        throw new SQLException(
            "Cannot read LocalTime using a " + columnInfo.getColumnType().getJavaTypeName()
                + " field");
    }

  }
1154636
public function buildQuery($type, $field = null, $extra = null)
    {
        if($type == 'select') {
            if($field == null) {
                $field = "*";
            }
            elseif(is_array($field)) {
                foreach($field as $i => $value) {
                    $field[$i] = '`'.trim($value).'`';
                }
                $field = trim(implode(' ,', $field));
            }
            $ex = '';
            if($extra != null && is_array($extra)) {
                foreach($extra as $i => $v) {
                    if($i == 'count') {
                        $ex .= 'COUNT';
                        if($v == null) {
                            $ex .= '(*)';
                        }
                    }
                    if($i == 'field') {
                        $ex .= ' as `'.$v.'`';
                    }
                }
                $sql = "SELECT $ex FROM `".$this->getTable().'` '.$this->where;
            }
            else {
                $sql = "SELECT $field FROM `".$this->getTable().'` '.$this->where.$this->order.$this->limit;
            }
        }
        elseif($type == 'insert') {
            if(is_array($field)) {
                $keys = array_keys($field);
                if($keys[0] === 0) {
                    $keys = '';
                }
                else {
                    foreach($keys as $i => $key) {
                        $keys[$i] = ' `'.trim($key).'`';
                    }
                    $keys = implode(',', $keys);
                }
                $values = array_values($field);
                foreach($values as $i => $val) {
                    $values[$i] = is_string($val) ? "'$val'" : $val;
                }
                $values = implode(' ,', $values);
            }
            else {
                $keys = '';
                $values = trim($field);
            }
            $values = "($values)";
            $keys = ($keys !== '') ? "($keys)" : '';
            $sql = "INSERT INTO `".$this->getTable()."` $keys VALUES $values".$this->duplicateUpdate;
        }
        elseif($type == 'update') {
            if(is_array($field)) {
                foreach($field as $key => $value) {
                    $values[] = " `$key` = ".(is_string($value) ? "'$value'" : $value);
                }
                $values = implode(' ,', $values);
            }
            else {
                $values = trim($field);
            }
            $sql = "UPDATE `".$this->getTable()."` SET $values ".$this->where;
        }
        elseif($type == 'delete') {
            $sql = "DELETE FROM `".$this->getTable()."` ".$this->where;
        }
        $this->query = $sql;
        return $sql;
    }
651796
public function addTemporalAccessorComment(&$script, Column $column)
    {
        $clo = $column->getLowercasedName();

        $dateTimeClass = $this->getDateTimeClass($column);

        $handleMysqlDate = false;
        if ($this->getPlatform() instanceof MysqlPlatform) {
            if ($column->getType() === PropelTypes::TIMESTAMP) {
                $handleMysqlDate = true;
                $mysqlInvalidDateString = '0000-00-00 00:00:00';
            } elseif ($column->getType() === PropelTypes::DATE) {
                $handleMysqlDate = true;
                $mysqlInvalidDateString = '0000-00-00';
            }
            // 00:00:00 is a valid time, so no need to check for that.
        }

        $script .= "
    /**
     * Get the [optionally formatted] temporal [$clo] column value.
     * {$column->getDescription()}
     *
     * @param      string|null \$format The date/time format string (either date()-style or strftime()-style).
     *                            If format is NULL, then the raw $dateTimeClass object will be returned.
     *
     * @return string|$dateTimeClass Formatted date/time value as string or $dateTimeClass object (if format is NULL), NULL if column is NULL" .($handleMysqlDate ? ', and 0 if column value is ' . $mysqlInvalidDateString : '')."
     *
     * @throws PropelException - if unable to parse/validate the date/time value.
     */";
    }
1127717
def get_timestamp_column(expression, column_name):
        """"""
        if expression:
            return expression
        elif column_name.lower() != column_name:
            return f'"{column_name}"'
        return column_name
587568
public static void sqltimestampdiff(StringBuilder buf, List<? extends CharSequence> parsedArgs) throws SQLException {
    if (parsedArgs.size() != 3) {
      throw new PSQLException(
          GT.tr("{0} function takes three and only three arguments.", "timestampdiff"),
          PSQLState.SYNTAX_ERROR);
    }
    buf.append("extract( ")
        .append(constantToDatePart(buf, parsedArgs.get(0).toString()))
        .append(" from (")
        .append(parsedArgs.get(2))
        .append("-")
        .append(parsedArgs.get(1))
        .append("))");
  }
331698
public function column($column, $type = 'string', $length = 255)
    {
        $this->builder->setDiscriminatorColumn($column, $type, $length);

        return $this;
    }
1045652
public function convertStringToPHPValue(AbstractSpatialType $type, $sqlExpr)
    {
        $parser = new StringParser($sqlExpr);

        return $this->newObjectFromValue($type, $parser->parse());
    }
335367
protected function _run(string $type, string $table, string $sql=NULL, array $vals=NULL, bool $reset=TRUE): PDOStatement
	{
		if ($sql === NULL)
		{
			$sql = $this->_compile($type, $table);
		}

		if ($vals === NULL)
		{
			$vals = array_merge($this->state->getValues(), $this->state->getWhereValues());
		}

		$startTime = microtime(TRUE);

		$res = empty($vals)
			? $this->driver->query($sql)
			: $this->driver->prepareExecute($sql, $vals);

		$endTime = microtime(TRUE);
		$totalTime = number_format($endTime - $startTime, 5);

		// Add this query to the list of executed queries
		$this->_appendQuery($vals, $sql, (int) $totalTime);

		// Reset class state for next query
		if ($reset)
		{
			$this->resetQuery();
		}

		return $res;
	}
251414
public java.sql.Time getTime(String column) {
		return (java.sql.Time)getColumns().get(column);
	}
828556
public Time getInternalTime(ColumnInformation columnInfo, Calendar cal, TimeZone timeZone)
      throws SQLException {
    if (lastValueWasNull()) {
      return null;
    }

    if (columnInfo.getColumnType() == ColumnType.TIMESTAMP
        || columnInfo.getColumnType() == ColumnType.DATETIME) {
      Timestamp timestamp = getInternalTimestamp(columnInfo, cal, timeZone);
      return (timestamp == null) ? null : new Time(timestamp.getTime());

    } else if (columnInfo.getColumnType() == ColumnType.DATE) {

      throw new SQLException("Cannot read Time using a Types.DATE field");

    } else {
      String raw = new String(buf, pos, length, StandardCharsets.UTF_8);
      if (!options.useLegacyDatetimeCode && (raw.startsWith("-") || raw.split(":").length != 3
          || raw.indexOf(":") > 3)) {
        throw new SQLException("Time format \"" + raw + "\" incorrect, must be HH:mm:ss");
      }
      boolean negate = raw.startsWith("-");
      if (negate) {
        raw = raw.substring(1);
      }
      String[] rawPart = raw.split(":");
      if (rawPart.length == 3) {
        int hour = Integer.parseInt(rawPart[0]);
        int minutes = Integer.parseInt(rawPart[1]);
        int seconds = Integer.parseInt(rawPart[2].substring(0, 2));
        Calendar calendar = Calendar.getInstance();
        if (options.useLegacyDatetimeCode) {
          calendar.setLenient(true);
        }
        calendar.clear();
        calendar.set(1970, Calendar.JANUARY, 1, (negate ? -1 : 1) * hour, minutes, seconds);
        int nanoseconds = extractNanos(raw);
        calendar.set(Calendar.MILLISECOND, nanoseconds / 1000000);

        return new Time(calendar.getTimeInMillis());
      } else {
        throw new SQLException(
            raw + " cannot be parse as time. time must have \"99:99:99\" format");
      }
    }

  }
872798
protected function validateDateTimeValue($value, $column)
    {
        $value = DateTimeHelper::makeCarbon($value, false);

        if (!$value instanceof Carbon) {
            throw new ApplicationException(Lang::get(
                'backend::lang.list.invalid_column_datetime',
                ['column' => $column->columnName]
            ));
        }

        return $value;
    }