getFieldsWithTableAlias

Return the array of fields with table aliases expanded.

@access public
@param  string $table_alias (null)
@return array
972573
public function getFieldsWithTableAlias($table_alias = null)
    {
        $vals = [];
        $replace = $table_alias === null ? '' : sprintf("%s.", $table_alias);

        foreach ($this->fields as $name => $definition) {
            $vals[$name] = $this->replaceToken($this->fields[$name], $replace);
        }

        return $vals;
    }
510964
public function getFieldByAlias($alias)
    {
        foreach ($this->_fields as $column => $fields)
        {
            foreach ($fields as $field)
            {
                if ($field->getAlias() === $alias)
                {
                    return $field;
                }
            }
        }
        return null;
    }
83795
protected static function getSkippedDisplayFields(RepositoryInterface $table, bool $aliased = false): array
    {
        /** @var \Cake\ORM\Table */
        $table = $table;

        if (! $aliased) {
            return static::$skipDisplayFields;
        }

        $result = [];
        foreach (static::$skipDisplayFields as $field) {
            $result[] = $table->aliasField($field);
        }

        return $result;
    }
1325695
public function getDefaultValuesFields(Table $table)
    {
        return $table->getFields()->filter(function (Field $field) {
            return $field->getDefault() !== null;
        });
    }
1118419
public function getColumns($table_name)
    {
        try
        {
            $q = $this->db->prepare("
                SELECT 
                        column_name, data_type, udt_name, 
                        is_nullable, column_default, numeric_precision,
                        numeric_scale, character_maximum_length 
                    FROM information_schema.columns 
                    WHERE table_name = :table AND table_schema = :schema
                    ORDER BY ordinal_position
            ");

            $q->execute(array("table" => $table_name, "schema" => $this->schema));

            if ($q->rowCount() === 0)
                throw new TableNotExistsException();

            return $q->fetchAll();
        }
        catch (PDOException $e)
        {
            throw new TableNotExistsException();
        }
    }
326451
public function getUnsignedFields(Table $table)
    {
        return $table->getFields()->filter(function (Field $field) {
            return $field->isUnsigned();
        });
    }
99385
public function getTablesNames()
    {
        $aTables      = array_keys($this->getTablesCreateSql());
        $prefixTables = $this->getTablePrefix();

        $return = array();
        foreach ($aTables as $table) {
            $return[] = $prefixTables . $table;
        }

        return $return;
    }
648529
public function table($table, $alias = null)
    {
        if ($alias) {
            $table = [$alias => $table];
        } elseif (!is_array($table)) {
            $table = [$table];
        }

        $this->joins = [];
        foreach ($table as $alias => $name) {
            if ($name instanceof QueryInterface) {
                $expression = '(' . $name->getQuery() . ')';
            } else {
                $expression = $this->connection->quoteIdentifier($name);
            }
            if (is_string($alias)) {
                $this->tables[$alias] = $expression . ' ' . $alias;
            } else {
                $this->tables[$name] = $expression;
            }
        }

        return $this;
    }
1085002
public function getFrom()
    {
        $result = [];
        $params = [];

        $refCount = $this->query->aliasRefCount;

        foreach ($this->query->tablesAliasList as $alias) {
            if (!ArrayHelper::getValue($refCount, $alias)) {
                continue;
            }

            try {
                /** @var $from BaseJoin */
                $from = ArrayHelper::getValue(
                    $this->query->tableJoinsMap,
                    $alias,
                    ArrayHelper::STRICT
                );

                list($fromSql, $fromParams) = $this->compile($from);
                array_push($result, $fromSql);

                $params = array_merge($params, $fromParams);
            } catch (KeyError $e) {
                continue;
            }
        }

        return [$result, $params];
    }
1099388
protected function get_fieldlist() : array {
        global $DB;

        if (null === $this->fields) {
            $fields = [];
            foreach (array_keys($DB->get_columns($this->tablename)) as $fieldname) {
                $fields["{$this->fieldprefix}{$fieldname}"] = $fieldname;
            }

            $this->fields = $fields;
        }

        return $this->fields;
    }
895501
final function FieldNames(array $aliases = array())
    {
        $fieldNames = array_keys($this->FieldMappers());
        $result = array();
        foreach ($fieldNames as $fieldName)
        {
            if (array_key_exists($fieldName, $aliases))
                $result[$aliases[$fieldName]] = $fieldName;
            else
                $result[] = $fieldName;
        }
        return $result;
    }
92328
public function getAlias() {
        //Check and see if there is another relationship with the same name
        $multipleFound = false;
        foreach($this->getRelationships() as $relationship) {
            if($relationship !== $this && $relationship->getRemoteTable() == $this->getRemoteTable()) {
                $multipleFound = true;
            }
        }
        $returnVar = '';
        if($multipleFound) {
            if($this->isPlural()) {
                $name = $this->getRemoteColumn();
                //Strip out local table
                if(stripos($name, $this->getRemoteTable()) === 0) {
                    $name = substr($name, strlen($this->getRemoteTable()));
                }
                //Strip out remote table name, with id
                if(stripos(substr($name, strlen($this->getLocalTable() . 'Id') * -1), $this->getLocalTable() . 'Id') === 0) {
                    $name = substr($name, 0, strlen($this->getLocalTable() . 'Id') * -1);
                }
            } else {
                $name = $this->getLocalColumn();
                //Strip out local table
                if(stripos($name, $this->getLocalTable()) === 0) {
                    $name = substr($name, strlen($this->getLocalTable()));
                }
                //Strip out remote table name, with id
                if(stripos(substr($name, strlen($this->getRemoteTable() . 'Id') * -1), $this->getRemoteTable() . 'Id') === 0) {
                    $name = substr($name, 0, strlen($this->getRemoteTable() . 'Id') * -1);
                }
            }
            $returnVar .= $name;
        }
        $returnVar .= $this->getRemoteShortModel();
        if($this->isPlural()) {
            $pluralHelper = new PluralHelper();
            $returnVar = $pluralHelper->pluralize($returnVar);
        }
        return ucfirst($returnVar);
    }
750403
public function get_fields(string $table = ''): ?array
  {
    if ( !empty($this->class_cfg) ){
      if ( $table ){
        return $this->class_cfg['arch'][$table] ?? null;
      }
      return $this->class_cfg['arch'];
    }
    return null;
  }
124391
protected function _getFields(Table $table)
    {
        $fields = explode(',', $this->args[1]);
        foreach ($fields as $field) {
            if (!$table->hasField($field)) {
                $this->abort(sprintf('Table `%s` is missing the field `%s`.', $table->table(), $field));
            }
        }

        return $fields;
    }
1098740
final function Table($alias = '', array $fieldAliases = array())
    {
        $sql = $this->SqlBuilder();
        return $sql->Table($this->TableName(), $this->FieldNames($fieldAliases), $alias);
    }
639987
public function getTableFields($tableName = '')
    {
        if ('' == $tableName) {
            $tableName = isset($this->options['table']) ? $this->options['table'] : $this->getTable();
        }

        return $this->connection->getTableFields($tableName);
    }
44634
protected static function get_fields_sql($target, $alias, $prefix) {
        switch ($target) {
            case 'grade_category':
            case 'grade_grade':
            case 'grade_item':
            case 'grade_outcome':
            case 'grade_scale':
                $obj = new $target([], false);
                $fields = array_merge(array_keys($obj->optional_fields), $obj->required_fields);
                break;

            case 'grade_grades_history':
                $fields = ['id', 'action', 'oldid', 'source', 'timemodified', 'loggeduser', 'itemid', 'userid', 'rawgrade',
                    'rawgrademax', 'rawgrademin', 'rawscaleid', 'usermodified', 'finalgrade', 'hidden', 'locked', 'locktime',
                    'exported', 'overridden', 'excluded', 'feedback', 'feedbackformat', 'information', 'informationformat'];
                break;

            default:
                throw new \coding_exception('Unrecognised target: ' . $target);
                break;
        }

        return implode(', ', array_map(function($field) use ($alias, $prefix) {
            return "{$alias}.{$field} AS {$prefix}{$field}";
        }, $fields));
    }