Execute the query as a "select" statement.

@param  array  $columns
@return \Nova\Database\ORM\Collection|static[]
543553
public function get($columns = array('*'))
    {
        $models = $this->getModels($columns);

        if (count($models) > 0) {
            $models = $this->eagerLoadRelations($models);
        }

        return $this->model->newCollection($models);
    }
1260837
public function fetchData($columns = null)
    {

        // auto populate columns with arrays from the existing Table
        // when user does not supply a parameter to this function
        if($columns == null)
        {
            $this->_selectedColumns = $this->getTableColumns();
        }
        else
        {
            if(is_array($columns))
            {
                $this->_selectedColumns = $columns;
            }
            else
            {
                throw new \InvalidArgumentException('Invalid argument provided on Column parameter');
            }
        }

        $select = new Select();

        $select->columns(array_keys($this->_selectedColumns));
        $select->from($this->tableGateway->getTable());
        $resultSet = $this->tableGateway->selectWith($select);
        $resultSet->buffer();
        $this->_selectedValues = $resultSet;

        return $resultSet;

    }
605070
public function select($columns = null)
	{
		$columns = func_get_args();

		$this->_select = array_merge($this->_select, $columns);

		return $this;
	}
247601
public function makeSelect(array $columns = null)
    {
        $columns = $columns ?: $this->columns();
        $selects = [];

        foreach ($columns as $key => $select) {
            if (is_int($key)) {
                $selects[] = $select;
            } else {
                $selects[] = DB::raw($select.' as '.$key);
            }
        }

        return $selects;
    }
106282
protected function getSelectColumns( $columns = null )
    {
        if ( null === $columns )
        {
            $label = true;
        }
        elseif ( ( $index = array_search( 'label', $columns ) ) )
        {
            $label = true;
            unset( $columns[$index] );
        }
        else
        {
            $label = false;
        }

        if ( null === $columns )
        {
            $proxyData = true;
        }
        elseif ( ( $index = array_search( 'proxyData', $columns ) ) )
        {
            $proxyData = true;
            unset( $columns[$index] );
        }
        else
        {
            $proxyData = false;
        }

        if ( null === $columns )
        {
            $level = false;
        }
        elseif ( ( $index = array_search( 'level', $columns ) ) )
        {
            $level = true;
            unset( $columns[$index] );
        }
        else
        {
            $level = false;
        }

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

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

            $columns['label'] = new Sql\Expression( '(' .
                $this->sql( $this->getTableInSchema(
                        static::$labelTableName
                     ) )
                     ->select()
                     ->columns( array( 'label' ) )
                     ->where( array(
                         new Sql\Predicate\Expression(
                             $platform->quoteIdentifierChain( array(
                                 static::$labelTableName, 'menuId'
                             ) ) .
                             ' = ' .
                             $platform->quoteIdentifierChain( array(
                                 static::$tableName, 'id'
                             ) )
                         )
                     ) )
                     ->order( array(
                         new Sql\Expression(
                             'CASE ? ' .
                                 'WHEN ? THEN 1 ' .
                                 'WHEN ? THEN 2 ' .
                                 'WHEN ? THEN 3 ' .
                                 'WHEN ? THEN 4 ' .
                                 'ELSE 5 ' .
                             'END ASC',
                             array(
                                 'locale',
                                 $this->getLocale(),
                                 $this->getPrimaryLanguage(),
                                 $this->getDefaultLocale(),
                                 'en',
                             ),
                             array(
                                 Sql\Expression::TYPE_IDENTIFIER,
                                 Sql\Expression::TYPE_VALUE,
                                 Sql\Expression::TYPE_VALUE,
                                 Sql\Expression::TYPE_VALUE,
                                 Sql\Expression::TYPE_VALUE,
                             )
                         ),
                     ) )
                     ->limit( 1 )
                     ->getSqlString( $platform ) .
            ')' );
        }

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

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

        if ( $level )
        {
            $columns['level'] = new Sql\Expression( '(' .
                $this->sql( null )
                     ->select( array(
                         'ascendants' => static::$tableName,
                     ) )
                     ->columns( array( new Sql\Expression( 'COUNT(*) - 1' ) ) )
                     ->where( array(
                         new Sql\Predicate\Expression(
                             $platform->quoteIdentifierChain( array(
                                 static::$tableName, 'left'
                             ) ) .
                             ' BETWEEN ' .
                             $platform->quoteIdentifierChain( array(
                                 'ascendants', 'left'
                             ) ) .
                             ' AND ' .
                             $platform->quoteIdentifierChain( array(
                                 'ascendants', 'right'
                             ) )
                         )
                     ) )
                     ->getSqlString( $platform ) .
            ')' );
        }

        return $columns;
    }
68741
private function processColumns(array $columns): array
    {
        $results = [];

        foreach ($columns as $column) {
            $types = [$column->phpType()];

            if ($column->isNullable()) {
                $types[] = 'null';
            }

            $results[$column->getName()] = $types;
        }

        return $results;
    }
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;
    }
1013542
public function addSelectColumns(array $columns)
    {
        foreach ($columns as $column) {
            is_array($column)
                ? count($column) != count($column, true)
                ? $this->addSelectColumns(...$column) : $this->addSelectColumn(...$column) : $this->addSelectColumn($column);
        }
        
        return $this;
    }
1838
protected function shouldSelect(array $columns = ['*'])
    {
        if ($columns === ['*']) {
            $columns = [$this->related->getTable() . '.*'];
        }

        return array_merge($columns, $this->aliasedPivotColumns());
    }
740564
public function addSelect($columns) {
		if(is_array($columns))
			return $this->_addSelect($columns);

		$columns = explode(',', $columns);
		foreach($columns as $columnstr) {
			$columnstr = trim($columnstr);

			preg_match('/(.*?)\s+as\s+([a-z_][a-zA-Z0-9_]*)?$/i', $columnstr, $matches);
			if(isset($matches[2])) {
				$alias = $matches[2];
				$column = $matches[1];
			}
			else
				$alias = $column = $columnstr;

			if(isset($this->columns[$alias]))
				throw new \Exception('Column alias '.$alias.' is already used.');
			$this->columns[$alias] = $column;
		}

		return $this;
	}
725354
public function columns(array $columns)
    {
        foreach ($columns as $name => $value) {
            $this->columns[$this->grammar->buildId($name)] = $value;
        }

        return $this;
    }
309307
public function select($columns = [])
    {
        $expr = new ColumnExpression($this->sql);

        if ($columns instanceof Closure) {
            $columns($expr);
        } else {
            if (!is_array($columns)) {
                $columns = [$columns];
            }
            $expr->columns($columns);
        }
    }
210782
public function select($columns) {
        SelectImpl::select($this->context, $columns);
        return new FromRule($this->context);
    }
836783
public function getFresh($columns = array('*'))
	{
		if (is_null($this->columns)) $this->columns = $columns;

        return $this->runSelect();
	}
19438
public function getFresh($columns = array('*'))
    {
        if (is_null($this->columns)) $this->columns = $columns;

        return $this->processor->processSelect($this, $this->runSelect());
    }
161741
protected function getFresh($columns = [])
    {
        // If no columns have been specified for the select statement, we will set them
        // here to either the passed columns, or the standard default of retrieving
        // all of the columns on the table using the "wildcard" column character.
        if (is_null($this->columns)) {
            $this->columns = $columns;
        }

        // Drop all columns if * is present, MongoDB does not work this way.
        if (in_array('*', $this->columns)) {
            $this->columns = [];
        }

        // Compile wheres
        $wheres = $this->compileWheres();

        // Use MongoDB's aggregation framework when using grouping or aggregation functions.
        if ($this->groups || $this->aggregate) {
            return $this->getFreshGroupAndAggregate($wheres);
        }

        // Return distinct results directly
        if ($this->distinct) {
            return $this->getFreshDistinct($wheres);
        }

        return $this->getFreshNormal($wheres);
    }
1092732
public function getFresh($columns = array('*'))
	{
		// If no columns have been specified for the select statement, we will set them
		// here to either the passed columns, or the standard default of retrieving
		// all of the columns on the table using the "wildcard" column character.
		if (is_null($this->columns))
		{
			$this->columns = $columns;
		}

		// Drop all columns if * is present, MongoDB does not work this way
		if (in_array('*', $this->columns))
		{
			$this->columns = array();
		}

		// Compile wheres
		$wheres = $this->compileWheres();

		// Aggregation query.
		if (isset($this->aggregate['function']))
		{
			switch ($this->aggregate['function'])
			{
				case 'count':
					$result = $this->collection->group(array(
						'key' => array('_id' => true),
						'initial' => array('count' => 0),
						'reduce' => "function(doc,out){ out.count++;}",
						'condition' => $wheres,

					));

					$result = count($result);
					break;

				case 'max':
				case 'min':
					$result = $this->collection->query(array(
						'query' => $wheres,
						'fields' => $this->columns,
						'sort' => array($this->columns[0] => $this->aggregate['function'] === 'max' ? -1 : 1),
						'limit' => 1,
					));
					$result = empty($result) ? 0 : $result[0][$this->columns[0]];
					break;

				default:
					$result = array();
					break;
			}

			return array(
				array(
					'aggregate' => $result,
				),
			);
		}
		// Normal query
		else
		{
			// Execute query.
			return $this->collection->query(array(
				'query' => $wheres,
				'fields' => $this->columns,
				'sort' => $this->orders,
				'skip' => $this->offset,
				'limit' => $this->limit,
			));
		}
	}