@param bool $use_alias

@return ColumnSchema[]
518059
public function getColumns($use_alias = false)
    {
        if ($use_alias) {
            // re-index for alias usage, easier to find requested fields from client
            $columns = [];
            /** @var ColumnSchema $column */
            foreach ($this->columns as $column) {
                $columns[strtolower($column->getName(true))] = $column;
            }

            return $columns;
        }

        return $this->columns;
    }
510964
public function getFieldByAlias($alias)
    {
        foreach ($this->_fields as $column => $fields)
        {
            foreach ($fields as $field)
            {
                if ($field->getAlias() === $alias)
                {
                    return $field;
                }
            }
        }
        return null;
    }
848438
public function groupByToSql(bool $useClause = true): array
    {
        $sql = $params = [];

        foreach ($this->groupBy as $groupBy) {
            $sql[] = $groupBy['sql'];

            $groupBy['params'] && $params = array_merge($params, $groupBy['params']);
        }

        $sql = implode(', ', $sql);

        if ($sql and $useClause) {
            $sql = 'GROUP BY ' . $sql;
        }

        return [$sql, $params];
    }
1229188
public function formatUpdateFields(array $fields, $alias = null) {
        $columns = [];

        if ($alias) {
            $alias = $this->quote($alias) . '.';
        }

        foreach ($fields as $key => $value) {
            if ($value instanceof Expr) {
                $columns[] = $alias . $this->quote($key) . ' = ' . $this->formatExpression($value);

            } else {
                $columns[] = $alias . $this->quote($key) . ' = ?';
            }
        }

        return $columns;
    }
135791
protected function getAliasesByExtendsNamespace()
    {
        $aliases = $this->getValidAliases();

        $aliases = $aliases->filter(function (Alias $item) {
            return ! collect([
                'MessageStack',
                'AdminSection',
                'AdminTemplate',
                'AdminNavigation',
                'AdminColumn',
                'AdminColumnEditable',
                'AdminColumnFilter',
                'AdminDisplayFilter',
                'AdminForm',
                'AdminFormElement',
                'AdminDisplay',
            ])->search($item->getAlias());
        });

        return $aliases->groupBy(function (Alias $alias) {
            return $alias->getExtendsNamespace();
        });
    }
783743
function alias( $aliasName )
    {
        $aliasList = $this->aliasList();
        if ( !array_key_exists( $aliasName, $aliasList ) )
            return false;
        return $aliasList[$aliasName];
    }
1371478
public function get_tables($usecache=true) {
        $tables = array();

        $sql = 'SELECT name FROM sqlite_master WHERE type="table" UNION ALL SELECT name FROM sqlite_temp_master WHERE type="table" ORDER BY name';
        if ($this->debug) {
            $this->debug_query($sql);
        }
        $rstables = $this->pdb->query($sql);
        foreach ($rstables as $table) {
            $table = $table['name'];
            $table = strtolower($table);
            if ($this->prefix !== false && $this->prefix !== '') {
                if (strpos($table, $this->prefix) !== 0) {
                    continue;
                }
                $table = substr($table, strlen($this->prefix));
            }
            $tables[$table] = $table;
        }
        return $tables;
    }
989521
public function getColumns($bWithoutForeignKey = true, $bAliased = true, $bPrefixed = false)
    {
        $aColumns = $this->columns;

        if ($bWithoutForeignKey) {
            $aColumns = $this->removeForeignKeyColumns($aColumns);
        }

        if ($bAliased) {
            $aColumns = $this->aliaseColumns($aColumns, $this->getAlias());
        }

        if ($bPrefixed) {
            $aColumns = $this->prefixeColumns($aColumns, $this->getAlias());
        }

        return $aColumns;
    }
986503
public function formatSelectFields(array $fields, $alias = null) {
        $columns = [];
        $quotedAlias = $alias ? $this->quote($alias) . '.' : '';
        $virtualJoins = $this->getConfig('virtualJoins');

        if (empty($fields)) {
            $columns[] = $quotedAlias . '*';

        } else {
            foreach ($fields as $field) {
                if ($field instanceof Func) {
                    $columns[] = $this->formatFunction($field);

                } else if ($field instanceof Expr) {
                    $columns[] = $this->formatExpression($field);

                } else if ($field instanceof RawExpr) {
                    $columns[] = $field->getValue(); // must come after other expressions

                } else if ($field instanceof SubQuery) {
                    $columns[] = $this->formatSubQuery($field);

                } else if (preg_match('/^(.*?)\s+AS\s+(.*?)$/i', $field, $matches)) {
                    $columns[] = sprintf($this->getClause(self::AS_ALIAS), $quotedAlias . $this->quote($matches[1]), $this->quote($matches[2]));

                // Alias the field for drivers that don't support PDO::getColumnMeta()
                } else if ($virtualJoins && $alias) {
                    $columns[] = sprintf($this->getClause(self::AS_ALIAS), $quotedAlias . $this->quote($field), $alias . '__' . $field);

                } else {
                    $columns[] = $quotedAlias . $this->quote($field);
                }
            }
        }

        return $columns;
    }
374051
public function get_columns($table, $usecache=true) {
        if ($usecache) {
            if ($this->temptables->is_temptable($table)) {
                if ($data = $this->get_temp_tables_cache()->get($table)) {
                    return $data;
                }
            } else {
                if ($data = $this->get_metacache()->get($table)) {
                    return $data;
                }
            }
        }

        $structure = array();

        $tablename = $this->prefix.$table;

        $sql = "SELECT a.attnum, a.attname AS field, t.typname AS type, a.attlen, a.atttypmod, a.attnotnull, a.atthasdef, d.adsrc
                  FROM pg_catalog.pg_class c
                  JOIN pg_catalog.pg_namespace as ns ON ns.oid = c.relnamespace
                  JOIN pg_catalog.pg_attribute a ON a.attrelid = c.oid
                  JOIN pg_catalog.pg_type t ON t.oid = a.atttypid
             LEFT JOIN pg_catalog.pg_attrdef d ON (d.adrelid = c.oid AND d.adnum = a.attnum)
                 WHERE relkind = 'r' AND c.relname = '$tablename' AND c.reltype > 0 AND a.attnum > 0
                       AND (ns.nspname = current_schema() OR ns.oid = pg_my_temp_schema())
              ORDER BY a.attnum";

        $this->query_start($sql, null, SQL_QUERY_AUX);
        $result = pg_query($this->pgsql, $sql);
        $this->query_end($result);

        if (!$result) {
            return array();
        }
        while ($rawcolumn = pg_fetch_object($result)) {

            $info = new stdClass();
            $info->name = $rawcolumn->field;
            $matches = null;

            if ($rawcolumn->type === 'varchar') {
                $info->type          = 'varchar';
                $info->meta_type     = 'C';
                $info->max_length    = $rawcolumn->atttypmod - 4;
                $info->scale         = null;
                $info->not_null      = ($rawcolumn->attnotnull === 't');
                $info->has_default   = ($rawcolumn->atthasdef === 't');
                if ($info->has_default) {
                    $parts = explode('::', $rawcolumn->adsrc);
                    if (count($parts) > 1) {
                        $info->default_value = reset($parts);
                        $info->default_value = trim($info->default_value, "'");
                    } else {
                        $info->default_value = $rawcolumn->adsrc;
                    }
                } else {
                    $info->default_value = null;
                }
                $info->primary_key   = false;
                $info->binary        = false;
                $info->unsigned      = null;
                $info->auto_increment= false;
                $info->unique        = null;

            } else if (preg_match('/int(\d)/i', $rawcolumn->type, $matches)) {
                $info->type = 'int';
                if (strpos($rawcolumn->adsrc, 'nextval') === 0) {
                    $info->primary_key   = true;
                    $info->meta_type     = 'R';
                    $info->unique        = true;
                    $info->auto_increment= true;
                    $info->has_default   = false;
                } else {
                    $info->primary_key   = false;
                    $info->meta_type     = 'I';
                    $info->unique        = null;
                    $info->auto_increment= false;
                    $info->has_default   = ($rawcolumn->atthasdef === 't');
                }
                // Return number of decimals, not bytes here.
                if ($matches[1] >= 8) {
                    $info->max_length = 18;
                } else if ($matches[1] >= 4) {
                    $info->max_length = 9;
                } else if ($matches[1] >= 2) {
                    $info->max_length = 4;
                } else if ($matches[1] >= 1) {
                    $info->max_length = 2;
                } else {
                    $info->max_length = 0;
                }
                $info->scale         = null;
                $info->not_null      = ($rawcolumn->attnotnull === 't');
                if ($info->has_default) {
                    // PG 9.5+ uses ::<TYPE> syntax for some defaults.
                    $parts = explode('::', $rawcolumn->adsrc);
                    if (count($parts) > 1) {
                        $info->default_value = reset($parts);
                    } else {
                        $info->default_value = $rawcolumn->adsrc;
                    }
                    $info->default_value = trim($info->default_value, "()'");
                } else {
                    $info->default_value = null;
                }
                $info->binary        = false;
                $info->unsigned      = false;

            } else if ($rawcolumn->type === 'numeric') {
                $info->type = $rawcolumn->type;
                $info->meta_type     = 'N';
                $info->primary_key   = false;
                $info->binary        = false;
                $info->unsigned      = null;
                $info->auto_increment= false;
                $info->unique        = null;
                $info->not_null      = ($rawcolumn->attnotnull === 't');
                $info->has_default   = ($rawcolumn->atthasdef === 't');
                if ($info->has_default) {
                    // PG 9.5+ uses ::<TYPE> syntax for some defaults.
                    $parts = explode('::', $rawcolumn->adsrc);
                    if (count($parts) > 1) {
                        $info->default_value = reset($parts);
                    } else {
                        $info->default_value = $rawcolumn->adsrc;
                    }
                    $info->default_value = trim($info->default_value, "()'");
                } else {
                    $info->default_value = null;
                }
                $info->max_length    = $rawcolumn->atttypmod >> 16;
                $info->scale         = ($rawcolumn->atttypmod & 0xFFFF) - 4;

            } else if (preg_match('/float(\d)/i', $rawcolumn->type, $matches)) {
                $info->type = 'float';
                $info->meta_type     = 'N';
                $info->primary_key   = false;
                $info->binary        = false;
                $info->unsigned      = null;
                $info->auto_increment= false;
                $info->unique        = null;
                $info->not_null      = ($rawcolumn->attnotnull === 't');
                $info->has_default   = ($rawcolumn->atthasdef === 't');
                if ($info->has_default) {
                    // PG 9.5+ uses ::<TYPE> syntax for some defaults.
                    $parts = explode('::', $rawcolumn->adsrc);
                    if (count($parts) > 1) {
                        $info->default_value = reset($parts);
                    } else {
                        $info->default_value = $rawcolumn->adsrc;
                    }
                    $info->default_value = trim($info->default_value, "()'");
                } else {
                    $info->default_value = null;
                }
                // just guess expected number of deciaml places :-(
                if ($matches[1] == 8) {
                    // total 15 digits
                    $info->max_length = 8;
                    $info->scale      = 7;
                } else {
                    // total 6 digits
                    $info->max_length = 4;
                    $info->scale      = 2;
                }

            } else if ($rawcolumn->type === 'text') {
                $info->type          = $rawcolumn->type;
                $info->meta_type     = 'X';
                $info->max_length    = -1;
                $info->scale         = null;
                $info->not_null      = ($rawcolumn->attnotnull === 't');
                $info->has_default   = ($rawcolumn->atthasdef === 't');
                if ($info->has_default) {
                    $parts = explode('::', $rawcolumn->adsrc);
                    if (count($parts) > 1) {
                        $info->default_value = reset($parts);
                        $info->default_value = trim($info->default_value, "'");
                    } else {
                        $info->default_value = $rawcolumn->adsrc;
                    }
                } else {
                    $info->default_value = null;
                }
                $info->primary_key   = false;
                $info->binary        = false;
                $info->unsigned      = null;
                $info->auto_increment= false;
                $info->unique        = null;

            } else if ($rawcolumn->type === 'bytea') {
                $info->type          = $rawcolumn->type;
                $info->meta_type     = 'B';
                $info->max_length    = -1;
                $info->scale         = null;
                $info->not_null      = ($rawcolumn->attnotnull === 't');
                $info->has_default   = false;
                $info->default_value = null;
                $info->primary_key   = false;
                $info->binary        = true;
                $info->unsigned      = null;
                $info->auto_increment= false;
                $info->unique        = null;

            }

            $structure[$info->name] = new database_column_info($info);
        }

        pg_free_result($result);

        if ($usecache) {
            if ($this->temptables->is_temptable($table)) {
                $this->get_temp_tables_cache()->set($table, $structure);
            } else {
                $this->get_metacache()->set($table, $structure);
            }
        }

        return $structure;
    }
1312881
protected function getDoctrineColumnAliases(ColumnDefinition $columnMetadata)
    {
        if (in_array($columnMetadata['type'], array_keys($this->aliases))) {
            $index = $columnMetadata['type'];

            // fix for nullable datetime
            if ($columnMetadata['type'] == 'dateTime' && ! empty($columnMetadata['nullable'])) {
                $this->aliases['dateTime']['options'] = array_except($this->aliases['dateTime']['options'], 'default');
            }

            // update primary key
            if (! empty($this->aliases[$index]['primary'])) {
                $columnMetadata['primary'] = $this->aliases[$index]['primary'];
            }

            // update unsigned
            if (! empty($this->aliases[$index]['options']['unsigned'])) {
                $columnMetadata['unsigned'] = $this->aliases[$index]['options']['unsigned'];
            }

            // update options
            if (! empty($this->aliases[$index]['options'])) {
                $columnMetadata['options'] = array_merge($columnMetadata['options'], $this->aliases[$index]['options']);
            }

            // update type
            $columnMetadata['type'] = $this->aliases[$index]['type'];
        }

        return $columnMetadata;
    }
1197777
public function getColumnByAlias($alias)
    {
        return $this->hasColumnAlias($alias) ? $this->getExpression($this->getHash($alias)) : null;
    }
213756
public function __column(string $column, string $index_key = null):array{
		return array_column($this->__toArray(), $column, $index_key);
	}
313482
public function aliasedColumn($query, $columnName, $tableName = null)
    {
        return $this->alias(
            $this->quoteColumn($columnName, $tableName),
            $this->quoteIdentifier(
                ($tableName ? $tableName . '_' : '') .
                $columnName
            )
        );
    }
1298499
public function getListDepartments($includeBlock = true) {
		$fields = [
			$this->alias . '.id',
			$this->alias . '.value',
		];
		$conditions = [];
		$blockExists = $this->hasField('block');
		if (!$includeBlock && $blockExists) {
			$conditions[$this->alias . '.block'] = false;
		}
		$order = [$this->alias . '.value' => 'asc'];
		$this->recursive = -1;

		return $this->find('list', compact('fields', 'conditions', 'order'));
	}
1348170
public function getBankList($use_cache = true)
    {
        if ($use_cache && self::$listOfBanks != null) {
            return self::$listOfBanks;
        }

        // Params
        $params = array(
            'a' => 'banklist',
            'testmode' => ($this->testMode) ? 'true' : 'false',
        );

        // Do request
        $xml = $this->request('ideal', $params);

        // List of banks
        $banks = array();

        foreach ($xml->bank as $bank) {
            $banks[(string) $bank->bank_id] = new Bank($bank->bank_id, $bank->bank_name);
        }

        // Cache?
        if ($use_cache) {
            self::$listOfBanks = $banks;
        }

        return $banks;
    }
671967
public static function GetColumns ($forced_obtain = false, $options = []) {
		$options += $options + static::GetDefaultOptions();
		return DBI::GetColumns($options, static::GetName(), $forced_obtain);
	}