src/xPDO/Om/xPDOObject.php
public static function getSelectColumns(xPDO & $xpdo, $className, $tableAlias= '', $columnPrefix= '', $columns= array (), $exclude= false) {
        $columnarray= array ();
        $aColumns= $xpdo->getFields($className);
        if ($aColumns) {
            if (!empty ($tableAlias)) {
                $tableAlias= $xpdo->escape($tableAlias);
                $tableAlias.= '.';
            }
            if (!$exclude && !empty($columns)) {
                foreach ($columns as $column) {
                    if (!in_array($column, array_keys($aColumns))) {
                        continue;
                    }
                    $columnarray[$column]= "{$tableAlias}" . $xpdo->escape($column);
                    if (!empty ($columnPrefix)) {
                        $columnarray[$column]= $columnarray[$column] . " AS " . $xpdo->escape("{$columnPrefix}{$column}");
                    }
                }
            } else {
                foreach (array_keys($aColumns) as $k) {
                    if ($exclude && in_array($k, $columns)) {
                        continue;
                    }
                    elseif (empty ($columns)) {
                        $columnarray[$k]= "{$tableAlias}" . $xpdo->escape($k);
                    }
                    elseif ($exclude || in_array($k, $columns)) {
                        $columnarray[$k]= "{$tableAlias}" . $xpdo->escape($k);
                    } else {
                        continue;
                    }
                    if (!empty ($columnPrefix)) {
                        $columnarray[$k]= $columnarray[$k] . " AS " . $xpdo->escape("{$columnPrefix}{$k}");
                    }
                }
            }
        }
        return implode(', ', $columnarray);
    }
public static function getSelectColumns(xPDO & $xpdo, $className, $tableAlias= '', $columnPrefix= '', $columns= array (), $exclude= false) {
        $columnarray= array ();
        $aColumns= $xpdo->getFields($className);
        if ($aColumns) {
            if (!empty ($tableAlias)) {
                $tableAlias= $xpdo->escape($tableAlias);
                $tableAlias.= '.';
            }
            if (!$exclude && !empty($columns)) {
                foreach ($columns as $column) {
                    if (!in_array($column, array_keys($aColumns))) {
                        continue;
                    }
                    $columnarray[$column]= "{$tableAlias}" . $xpdo->escape($column);
                    if (!empty ($columnPrefix)) {
                        $columnarray[$column]= $columnarray[$column] . " AS " . $xpdo->escape("{$columnPrefix}{$column}");
                    }
                }
            } else {
                foreach (array_keys($aColumns) as $k) {
                    if ($exclude && in_array($k, $columns)) {
                        continue;
                    }
                    elseif (empty ($columns)) {
                        $columnarray[$k]= "{$tableAlias}" . $xpdo->escape($k);
                    }
                    elseif ($exclude || in_array($k, $columns)) {
                        $columnarray[$k]= "{$tableAlias}" . $xpdo->escape($k);
                    } else {
                        continue;
                    }
                    if (!empty ($columnPrefix)) {
                        $columnarray[$k]= $columnarray[$k] . " AS " . $xpdo->escape("{$columnPrefix}{$k}");
                    }
                }
            }
        }
        return implode(', ', $columnarray);
    }
public static function getSelectColumns ( xPDO & $ xpdo , $ className , $ tableAlias = '' , $ columnPrefix = '' , $ columns = array ( ) , $ exclude = false ) { $ columnarray = array ( ) ; $ aColumns = $ xpdo -> getFields ( $ className ) ; if ( $ aColumns ) { if ( ! empty ( $ tableAlias ) ) { $ tableAlias = $ xpdo -> escape ( $ tableAlias ) ; $ tableAlias .= '.' ; } if ( ! $ exclude && ! empty ( $ columns ) ) { foreach ( $ columns as $ column ) { if ( ! in_array ( $ column , array_keys ( $ aColumns ) ) ) { continue ; } $ columnarray [ $ column ] = "{$tableAlias}" . $ xpdo -> escape ( $ column ) ; if ( ! empty ( $ columnPrefix ) ) { $ columnarray [ $ column ] = $ columnarray [ $ column ] . " AS " . $ xpdo -> escape ( "{$columnPrefix}{$column}" ) ; } } } else { foreach ( array_keys ( $ aColumns ) as $ k ) { if ( $ exclude && in_array ( $ k , $ columns ) ) { continue ; } elseif ( empty ( $ columns ) ) { $ columnarray [ $ k ] = "{$tableAlias}" . $ xpdo -> escape ( $ k ) ; } elseif ( $ exclude || in_array ( $ k , $ columns ) ) { $ columnarray [ $ k ] = "{$tableAlias}" . $ xpdo -> escape ( $ k ) ; } else { continue ; } if ( ! empty ( $ columnPrefix ) ) { $ columnarray [ $ k ] = $ columnarray [ $ k ] . " AS " . $ xpdo -> escape ( "{$columnPrefix}{$k}" ) ; } } } } return implode ( ', ' , $ columnarray ) ; }
Get a set of column names from an xPDOObject for use in SQL queries.

@static
@param xPDO &$xpdo A reference to an initialized xPDO instance.
@param string $className The class name to get columns from.
@param string $tableAlias An optional alias for the table in the query.
@param string $columnPrefix An optional prefix to prepend to each column name.
@param array $columns An optional array of field names to include or exclude
(include is default behavior).
@param boolean $exclude Determines if any specified columns should be included
or excluded from the set of results.
@return string A comma-delimited list of the field names for use in a SELECT clause.
Get a set of column names from an xPDOObject for use in SQL queries .