@param $columns

@throws \Doctrine\DBAL\DBALException

@return array|string
491484
protected function buildColumns($columns)
    {
        if (!is_array($columns)) {
            if ($columns instanceof Aggregation) {
                $columns->setFieldsSql($this->buildColumns($columns->getFields()));

                return $this->getAdapter()->quoteSql($columns->toSQL());
            } elseif (false !== strpos($columns, '(')) {
                return $this->getAdapter()->quoteSql($columns);
            }
            $columns = preg_split('/\s*,\s*/', $columns, -1, PREG_SPLIT_NO_EMPTY);
        }
        foreach ($columns as $i => $column) {
            if ($column instanceof Expression) {
                $columns[$i] = $this->getAdapter()->quoteSql($column->toSQL());
            } elseif (false !== strpos($column, 'AS')) {
                if (preg_match('/^(.*?)(?i:\s+as\s+|\s+)([\w\-_\.]+)$/', $column, $matches)) {
                    list(, $rawColumn, $rawAlias) = $matches;
                    $columns[$i] = $this->getQuotedName($rawColumn).' AS '.$this->getQuotedName($rawAlias);
                }
            } elseif (false === strpos($column, '(')) {
                $columns[$i] = $this->getQuotedName($column);
            }
        }

        return is_array($columns) ? implode(', ', $columns) : $columns;
    }
1218697
protected function formatColumns($columns) : string {
    if (is_string($columns)) {
      if ($columns === '*') {
        return $columns;
      }

      $columns = explode(',', $columns);

      $columns = array_map(function ($column) {
        return '`' . trim($column) . '`';
      }, $columns);

      return implode(', ', $columns);
    }

    if (is_array($columns)) {
      return '`' . implode('`, `', $columns) . '`';
    }
  }
654499
protected function sanitizeColumns(array $columns)
    {
        $callback = $this->getCallback();
        if ($callback) {
            foreach ($columns as $key => $value) {
                $columns[$key] = $callback($value);
            }
        }

        if (!$this->enclosure) {
            return $columns;
        }

        foreach ($columns as $key => $value) {
            if (false !== strpos($value, $this->delimiter)
                || false !== strpos($value, $this->escape)
                || false !== strpos($value, $this->enclosure)
                || false !== strpos($value, $this->newline)
            ) {
                if ($this->escape != $this->enclosure) {
                    $value = str_replace($this->escape, $this->escape . $this->escape, $value);
                }
                $value = str_replace($this->enclosure, $this->escape . $this->enclosure, $value);
                $value = $this->enclosure . $value . $this->enclosure;

                $columns[$key] = $value;
            }
        }

        return $columns;
    }
557664
public function buildColumns($columns)
    {
        if (!is_array($columns)) {
            if (strpos($columns, '(') !== false) {
                return $columns;
            } else {
                $columns = preg_split('/\s*,\s*/', $columns, -1, PREG_SPLIT_NO_EMPTY);
            }
        }
        foreach ($columns as $i => $column) {
            if ($column instanceof Expression) {
                $columns[$i] = $column->expression;
            } elseif (strpos($column, '(') === false) {
                $columns[$i] = $this->db->quoteColumnName($column);
            }
        }

        return is_array($columns) ? implode(', ', $columns) : $columns;
    }
251498
public function select($columns = "*") : QueryBuilder
    {
        $this->_query[] = "SELECT";

        //Parse column(s)
        if(is_array($columns)) {
            $select_columns = "";

            $size = sizeof($columns);
            for($i = 0; $i < $size; $i++) {
                if($i > 0) {
                    $select_columns .= ', ';
                }

                $select_columns .= '`'. $this->sanitize((string)$columns[$i]) .'`';
            }

            $this->_query[] = $select_columns;

            return $this;
        }

        $select_columns = "*";
        if(
            !empty($columns) &&
            $columns !== "*"
        ) {
            $select_columns = '`'. $this->sanitize((string)$columns) .'`';
        }

        $this->_query[] = $select_columns;

        return $this;
    }
455856
public function columns($columns)
    {
        if (is_string($columns)) {
            $columns = preg_split('~\s*,\s*~', trim($columns));
        }

        $this->columns = $columns;

        return $this;
    }
1038054
protected function getTransfredFields(array $columns)
    {
        $collection = [];

        foreach ($columns as $column) {
            // While constructing the array for each field
            // there is no need to set translations for options
            // or even labels. This step is handled using the FieldTransformer
            $properties['name'] = $column->COLUMN_NAME;
            $properties['is-nullable'] = ($column->IS_NULLABLE == 'YES');
            $properties['data-value'] = $column->COLUMN_DEFAULT;
            $properties['data-type'] = $this->getDataType($column->DATA_TYPE, $column->COLUMN_TYPE);
            $properties['data-type-params'] = $this->getPrecision($column->CHARACTER_MAXIMUM_LENGTH, $column->DATA_TYPE, $column->COLUMN_TYPE);
            $properties['is-primary'] = in_array($column->COLUMN_KEY, ['PRIMARY KEY', 'PRI']);
            $properties['is-index'] = ($column->COLUMN_KEY == 'MUL');
            $properties['is-unique'] = ($column->COLUMN_KEY == 'UNI');
            $properties['is-auto-increment'] = ($column->EXTRA == 'AUTO_INCREMENT');
            $properties['comment'] = $column->COLUMN_COMMENT ?: null;
            $properties['options'] = $this->getHtmlOptions($column->DATA_TYPE, $column->COLUMN_TYPE);
            $properties['is-unsigned'] = (strpos($column->COLUMN_TYPE, 'unsigned') !== false);

            $constraint = $this->getForeignConstraint($column->COLUMN_NAME);

            $properties['foreign-constraint'] = !is_null($constraint) ? $constraint->toArray() : null;

            if (intval($column->CHARACTER_MAXIMUM_LENGTH) > 255
                || in_array($column->DATA_TYPE, $this->largeDataTypes)) {
                $properties['is-on-index'] = false;
            }

            $collection[] = $properties;
        }

        $localeGroup = Helpers::makeLocaleGroup($this->tableName);

        $fields = FieldTransformer::fromArray($collection, $localeGroup, $this->languages);

        // At this point we constructed the fields collection with the default html-type
        // We need to set the html-type using the config::getEloquentToHtmlMap() setting
        $this->setHtmlType($fields);

        return $fields;
    }
179596
public function get($columns = ['*'])
    {
        $cacheKey = $this->generateCacheKey();

        if (null === ($results = $this->cache->tags($this->cacheTag)->get($cacheKey))) {
            $results = parent::get($columns);

            if ($this->isTimeAwareQuery) {
                // Cache results for $cacheLifeTime minutes
                $this->cache->tags($this->cacheTag)->put($cacheKey, $results, $this->cacheLifeTime);
            } else {
                // Cache results forever
                $this->cache->tags($this->cacheTag)->forever($cacheKey, $results);
            }
        }


        return $results;
    }
344878
public function getAddColumnsDDL($columns)
    {
        $ret = '';
        foreach ($columns as $column) {
            $ret .= $this->getAddColumnDDL($column);
        }

        return $ret;
    }
560904
protected function getCachedRawAttributes(array $columns = null): array
    {
        $cachedAttributes = $this->getCache()->get($this->getEntityKeyValue());

        if (is_null($columns)) {
            return $cachedAttributes;
        }

        return array_only($cachedAttributes, $columns);
    }
1128377
protected function getColumnEnumeration( $columns ){
		$list	= array();
		foreach( $columns as $column )
			$list[]	= $column == '*' ? $column : '`'.$column.'`';
		return implode( ', ', $list );
	}
167807
protected function getSelectColumns( $columns = null )
    {
        if ( null === $columns )
        {
            $properties = true;
        }
        elseif ( ( $index = array_search( self::PROPERTIES_FIELD, $columns ) ) )
        {
            $properties = true;
            unset( $columns[$index] );
        }
        else
        {
            $properties = false;
        }

        $columns = parent::getSelectColumns( $columns );

        if ( $properties )
        {
            $platform = $this->getDbAdapter()
                             ->getPlatform();

            $columns[self::PROPERTIES_FIELD] = new Sql\Expression( '(' .
                $this->sql( $this->getTableInSchema(
                        static::$propertyTableName
                     ) )
                     ->select()
                     ->columns( array(
                         new Sql\Expression( 'TEXT( ARRAY_TO_JSON(
                             ARRAY_AGG( ? ORDER BY CHAR_LENGTH( ? ) ASC )
                         ) )', array(
                             static::$propertyTableName,
                             'name',
                         ), array(
                             Sql\Expression::TYPE_IDENTIFIER,
                             Sql\Expression::TYPE_IDENTIFIER,
                         ) )
                     ) )
                     ->where( array(
                         new Predicate\Expression(
                             $platform->quoteIdentifier( 'ruleId' ) .
                             ' = ' .
                             $platform->quoteIdentifierChain( array(
                                 static::$tableName, 'id'
                             ) )
                         )
                     ) )
                     ->getSqlString( $platform ) .
            ')' );
        }

        return $columns;
    }
193647
public static function getActiveDefaultColumns($columns)
	{
		$column = array();

		foreach($columns as $val) {
			$keyIndex = self::getKeyIndex($val);
			if($keyIndex)
				$column[] = $keyIndex;
		}

		return $column;
	}
1205812
private function buildColumns(array $columns)
    {
        $this->columns = [];
        foreach ($columns as $key => $column)
        {
            $column = new DataTableColumn($column);
            $this->columns[$key] = $column;
            if($column->getName() != ""){
                $this->columns[$column->getName()] = $column;
            }
            if($column->getData() != ""){
                $this->columns[$column->getData()] = $column;
            }
        }
    }
1126451
protected function getColumnHeaders($columns)
    {
        $headers = [];

        foreach ($columns as $column => $label) {
            $headers[] = Lang::get($label);
        }

        return $headers;
    }
133400
protected function handleColumns(array $columns)
    {
        if (empty($columns)) {
            return '*';
        }

        $sql = [];

        foreach ($columns as $column) {
            if ($column['alias'] !== null) {
                $sql[] = $this->wrap($column['name']) . ' AS ' . $this->wrap($column['alias']);
            } else {
                $sql[] = $this->wrap($column['name']);
            }
        }
        return implode(', ', $sql);
    }
1082579
public function columns(string $column, string ...$columns)
    {
        array_unshift($columns, $column);

        foreach ($columns as $column) {
            $this->column($column);
        }

        return $this;
    }