src/ORM/DataQuery.php
protected function selectColumnsFromTable(SQLSelect &$query, $tableClass, $columns = null)
    {
        // Add SQL for multi-value fields
        $schema = DataObject::getSchema();
        $databaseFields = $schema->databaseFields($tableClass, false);
        $compositeFields = $schema->compositeFields($tableClass, false);
        unset($databaseFields['ID']);
        foreach ($databaseFields as $k => $v) {
            if ((is_null($columns) || in_array($k, $columns)) && !isset($compositeFields[$k])) {
                // Update $collidingFields if necessary
                $expressionForField = $query->expressionForField($k);
                $quotedField = $schema->sqlColumnForField($tableClass, $k);
                if ($expressionForField) {
                    if (!isset($this->collidingFields[$k])) {
                        $this->collidingFields[$k] = array($expressionForField);
                    }
                    $this->collidingFields[$k][] = $quotedField;
                } else {
                    $query->selectField($quotedField, $k);
                }
            }
        }
        foreach ($compositeFields as $k => $v) {
            if ((is_null($columns) || in_array($k, $columns)) && $v) {
                $tableName = $schema->tableName($tableClass);
                $dbO = Injector::inst()->create($v, $k);
                $dbO->setTable($tableName);
                $dbO->addToQuery($query);
            }
        }
    }
protected function selectColumnsFromTable(SQLSelect &$query, $tableClass, $columns = null)
    {
        // Add SQL for multi-value fields
        $schema = DataObject::getSchema();
        $databaseFields = $schema->databaseFields($tableClass, false);
        $compositeFields = $schema->compositeFields($tableClass, false);
        unset($databaseFields['ID']);
        foreach ($databaseFields as $k => $v) {
            if ((is_null($columns) || in_array($k, $columns)) && !isset($compositeFields[$k])) {
                // Update $collidingFields if necessary
                $expressionForField = $query->expressionForField($k);
                $quotedField = $schema->sqlColumnForField($tableClass, $k);
                if ($expressionForField) {
                    if (!isset($this->collidingFields[$k])) {
                        $this->collidingFields[$k] = array($expressionForField);
                    }
                    $this->collidingFields[$k][] = $quotedField;
                } else {
                    $query->selectField($quotedField, $k);
                }
            }
        }
        foreach ($compositeFields as $k => $v) {
            if ((is_null($columns) || in_array($k, $columns)) && $v) {
                $tableName = $schema->tableName($tableClass);
                $dbO = Injector::inst()->create($v, $k);
                $dbO->setTable($tableName);
                $dbO->addToQuery($query);
            }
        }
    }
protected function selectColumnsFromTable ( SQLSelect & $ query , $ tableClass , $ columns = null ) { // Add SQL for multi-value fields $ schema = DataObject :: getSchema ( ) ; $ databaseFields = $ schema -> databaseFields ( $ tableClass , false ) ; $ compositeFields = $ schema -> compositeFields ( $ tableClass , false ) ; unset ( $ databaseFields [ 'ID' ] ) ; foreach ( $ databaseFields as $ k => $ v ) { if ( ( is_null ( $ columns ) || in_array ( $ k , $ columns ) ) && ! isset ( $ compositeFields [ $ k ] ) ) { // Update $collidingFields if necessary $ expressionForField = $ query -> expressionForField ( $ k ) ; $ quotedField = $ schema -> sqlColumnForField ( $ tableClass , $ k ) ; if ( $ expressionForField ) { if ( ! isset ( $ this -> collidingFields [ $ k ] ) ) { $ this -> collidingFields [ $ k ] = array ( $ expressionForField ) ; } $ this -> collidingFields [ $ k ] [ ] = $ quotedField ; } else { $ query -> selectField ( $ quotedField , $ k ) ; } } } foreach ( $ compositeFields as $ k => $ v ) { if ( ( is_null ( $ columns ) || in_array ( $ k , $ columns ) ) && $ v ) { $ tableName = $ schema -> tableName ( $ tableClass ) ; $ dbO = Injector :: inst ( ) -> create ( $ v , $ k ) ; $ dbO -> setTable ( $ tableName ) ; $ dbO -> addToQuery ( $ query ) ; } } }
Update the SELECT clause of the query with the columns from the given table

@param SQLSelect $query
@param string $tableClass Class to select from
@param array $columns
Update the SELECT clause of the query with the columns from the given table