Nette\Database\ResultSet::normalizeRow PHP Method

normalizeRow() public method

Normalizes result row.
public normalizeRow ( $row ) : array
return array
    public function normalizeRow($row)
    {
        if ($this->types === NULL) {
            $this->types = (array) $this->supplementalDriver->getColumnTypes($this->pdoStatement);
        }
        foreach ($this->types as $key => $type) {
            $value = $row[$key];
            if ($value === NULL || $value === FALSE || $type === IStructure::FIELD_TEXT) {
            } elseif ($type === IStructure::FIELD_INTEGER) {
                $row[$key] = is_float($tmp = $value * 1) ? $value : $tmp;
            } elseif ($type === IStructure::FIELD_FLOAT) {
                if (($pos = strpos($value, '.')) !== FALSE) {
                    $value = rtrim(rtrim($pos === 0 ? "0{$value}" : $value, '0'), '.');
                }
                $float = (double) $value;
                $row[$key] = (string) $float === $value ? $float : $value;
            } elseif ($type === IStructure::FIELD_BOOL) {
                $row[$key] = (bool) $value && $value !== 'f' && $value !== 'F';
            } elseif ($type === IStructure::FIELD_DATETIME || $type === IStructure::FIELD_DATE || $type === IStructure::FIELD_TIME) {
                $row[$key] = new Nette\Utils\DateTime($value);
            } elseif ($type === IStructure::FIELD_TIME_INTERVAL) {
                preg_match('#^(-?)(\\d+)\\D(\\d+)\\D(\\d+)\\z#', $value, $m);
                $row[$key] = new \DateInterval("PT{$m['2']}H{$m['3']}M{$m['4']}S");
                $row[$key]->invert = (int) (bool) $m[1];
            } elseif ($type === IStructure::FIELD_UNIX_TIMESTAMP) {
                $row[$key] = Nette\Utils\DateTime::from($value);
            }
        }
        return $this->supplementalDriver->normalizeRow($row);
    }