getColumnDetails

@param bool $refresh

@return mixed
495407
public function getColumnDetails($refresh = false)
    {
        if (empty($this->columnCache) || $refresh) {
            $query = PostgresqlGrammar::showTableColumns($this->db->replacePrefix($this->getName()));

            $fields = $this->db->setQuery($query)->loadAll();

            $result = [];

            foreach ($fields as $field) {
                // Do some dirty translation to MySQL output.
                $result[$field->column_name] = (object) [
                    'column_name' => $field->column_name,
                    'type' => $field->column_type,
                    'null' => $field->Null,
                    'Default' => $field->Default,
                    'Field' => $field->column_name,
                    'Type' => $field->column_type,
                    'Null' => $field->Null,
                    'Extra' => null,
                    'Privileges' => null,
                    'Comment' => $field->Comment,
                    'Key' => '',
                ];
            }

            $keys = $this->getIndexes();

            foreach ($result as $field) {
                if (strpos($field->Default, 'nextval') !== false) {
                    $field->Extra = 'auto_increment';
                    $field->Default = 0;
                }

                if (preg_match("/^NULL::*/", $field->Default)) {
                    $field->Default = null;
                }

                if (preg_match("/'(.*)'::[\w\s]/", $field->Default, $matches)) {
                    $field->Default = $matches[1] ?? '';
                }

                if (strpos($field->Type, 'character varying') !== false) {
                    $field->Type = str_replace('character varying', 'varchar', $field->Type);
                }

                // Find key
                $index = null;

                foreach ($keys as $key) {
                    if ($key->column_name == $field->column_name) {
                        $index = $key;
                        break;
                    }
                }

                if ($index) {
                    if ($index->is_primary) {
                        $field->Key = 'PRI';
                    } elseif ($index->is_unique) {
                        $field->Key = 'UNI';
                    } else {
                        $field->Key = 'MUL';
                    }
                }
            }

            $this->columnCache = $result;
        }

        return $this->columnCache;
    }
942156
public function getBrowserVersion($refresh = false)
    {
        if (empty($this->detection['browser']) || $refresh) {
            $this->detectBrowser($this->userAgent);
        }

        return $this->browserVersion;
    }
765360
public function getColumnsInfo($evidence = null)
    {
        $evidence = is_null($evidence) ? $this->getEvidence() : $evidence;
        if (!array_key_exists($evidence, $this->columnsInfo)) {
            $this->updateColumnsInfo($this->getOfflineColumnsInfo($evidence),
                $evidence);
        }
        return $this->columnsInfo[$evidence];
    }
783281
public function getConfig($refresh = false)
    {
        return $this->getCache('plugins-config', $refresh, function () {
            return [
                'wei' => [
                    'aliases' => $this->getWeiAliases(),
                ],
                'app' => [
                    'controllerMap' => $this->getAppControllerMap(),
                ],
                'plugin' => [
                    'pluginClasses' => $this->getPluginClasses(true),
                ],
            ];
        });
    }
739525
public function load($refresh = false)
    {
        $results = $this->repository->read();

        /* @var $config \Core\Config\ConfigObject */
        foreach ($results as $config) {
            $storage = $this->createStorage($config->getStorage());
            $storage->set($config->getId(), $config->getValue());
        }
    }
581994
private function get_column_info(stdClass $rawcolumn) {
        $rawcolumn = (object)$rawcolumn;
        $info = new stdClass();
        $info->name           = $rawcolumn->column_name;
        $info->type           = $rawcolumn->data_type;
        $info->meta_type      = $this->mysqltype2moodletype($rawcolumn->data_type);
        if ($this->has_breaking_change_quoted_defaults()) {
            $info->default_value = trim($rawcolumn->column_default, "'");
            if ($info->default_value === 'NULL') {
                $info->default_value = null;
            }
        } else {
            $info->default_value = $rawcolumn->column_default;
        }
        $info->has_default    = !is_null($info->default_value);
        $info->not_null       = ($rawcolumn->is_nullable === 'NO');
        $info->primary_key    = ($rawcolumn->column_key === 'PRI');
        $info->binary         = false;
        $info->unsigned       = null;
        $info->auto_increment = false;
        $info->unique         = null;
        $info->scale          = null;

        if ($info->meta_type === 'C') {
            $info->max_length = $rawcolumn->character_maximum_length;

        } else if ($info->meta_type === 'I') {
            if ($info->primary_key) {
                $info->meta_type = 'R';
                $info->unique    = true;
            }
            // Return number of decimals, not bytes here.
            $info->max_length    = $rawcolumn->numeric_precision;
            if (preg_match('/([a-z]*int[a-z]*)\((\d+)\)/i', $rawcolumn->column_type, $matches)) {
                $type = strtoupper($matches[1]);
                if ($type === 'BIGINT') {
                    $maxlength = 18;
                } else if ($type === 'INT' or $type === 'INTEGER') {
                    $maxlength = 9;
                } else if ($type === 'MEDIUMINT') {
                    $maxlength = 6;
                } else if ($type === 'SMALLINT') {
                    $maxlength = 4;
                } else if ($type === 'TINYINT') {
                    $maxlength = 2;
                } else {
                    // This should not happen.
                    $maxlength = 0;
                }
                // It is possible that display precision is different from storage type length,
                // always use the smaller value to make sure our data fits.
                if ($maxlength < $info->max_length) {
                    $info->max_length = $maxlength;
                }
            }
            $info->unsigned      = (stripos($rawcolumn->column_type, 'unsigned') !== false);
            $info->auto_increment= (strpos($rawcolumn->extra, 'auto_increment') !== false);

        } else if ($info->meta_type === 'N') {
            $info->max_length    = $rawcolumn->numeric_precision;
            $info->scale         = $rawcolumn->numeric_scale;
            $info->unsigned      = (stripos($rawcolumn->column_type, 'unsigned') !== false);

        } else if ($info->meta_type === 'X') {
            if ("$rawcolumn->character_maximum_length" === '4294967295') { // watch out for PHP max int limits!
                // means maximum moodle size for text column, in other drivers it may also mean unknown size
                $info->max_length = -1;
            } else {
                $info->max_length = $rawcolumn->character_maximum_length;
            }
            $info->primary_key   = false;

        } else if ($info->meta_type === 'B') {
            $info->max_length    = -1;
            $info->primary_key   = false;
            $info->binary        = true;
        }

        return $info;
    }
344242
public function getChunkCollection($refresh = false)
    {
        if ($refresh || !is_object($this->_chunkCollection)) {
            $this->_chunkCollection = Yii::createObject([
                'class' => 'yii\mongodb\Collection',
                'database' => $this->database,
                'name' => $this->getPrefix() . '.chunks'
            ]);
        }

        return $this->_chunkCollection;
    }
225865
protected function describeFunction($name, $refresh = false)
    {
        $name = (is_array($name) ? array_get($name, 'name') : $name);
        if (empty($name)) {
            throw new BadRequestException('Function name can not be empty.');
        }

        $this->checkPermission(Verbs::GET, $name);

        try {
            $function = $this->getFunction($name, $refresh);
            $result = $function->toArray();
            $result['access'] = $this->getPermissions($name);

            return $result;
        } catch (RestException $ex) {
            throw $ex;
        } catch (\Exception $ex) {
            throw new InternalServerErrorException("Failed to query database schema.\n{$ex->getMessage()}");
        }
    }
246137
protected function getSetOrEnum2Array($refTbl, $refCol)
    {
        $dat = $this->establishDatabaseAndTable($refTbl);
        foreach ($this->advCache['tableStructureCache'][$dat[0]][$dat[1]] as $vle) {
            if ($vle['COLUMN_NAME'] == $refCol) {
                $kVl = explode('\',\'', substr($vle['COLUMN_TYPE'], strlen($vle['DATA_TYPE']) + 2, -2));
                $fVl = array_combine($kVl, $kVl);
                if ($vle['IS_NULLABLE'] === 'YES') {
                    $fVl['NULL'] = '';
                }
            }
        }
        ksort($fVl);
        return $fVl;
    }
375917
public function getBrowser($refresh = false)
    {
        if (empty($this->detection['browser']) || $refresh) {
            $this->detectBrowser($this->userAgent);
        }

        return $this->browser;
    }
538113
public function getSelector(bool $refresh = false): string
    {
        if (!isset($this->selector) || $refresh) {
            $this->generateSelector();
        }

        return $this->selector;
    }
606602
protected function describeFunctions($names, $refresh = false)
    {
        $names = static::validateAsArray(
            $names,
            ',',
            true,
            'The request contains no valid function names or properties.'
        );

        $out = [];
        foreach ($names as $name) {
            $out[] = $this->describeFunction($name, $refresh);
        }

        return $out;
    }
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);
    }
558662
public function getFieldName($refresh = false)
    {
        if (!$this->fieldName || $refresh) {
            // Prevent double '/'
            $names = array_values(array_filter(explode('/', (string) $this->getName(true)), 'strlen'));

            $control = array_values(array_filter(explode('/', (string) $this->getControl()), 'strlen'));

            $names = array_merge($control, $names);

            $control = array_shift($names);

            $names = array_map(
                function ($value) {
                    return '[' . $value . ']';
                },
                $names
            );

            $this->fieldName = $control . implode('', $names);
        }

        return $this->fieldName;
    }
876915
public function columnDetail($detail)
    {
        $columnDetailString = '';

        if (stristr($detail, '(')) {
            $columnDetailString .= $detail;
        } else {
            $columnDetailString .= $detail.'()';
        }

        return $columnDetailString;
    }
597056
public function getTableColumns( $table, array $exclude = [ ] )
    {
        $query = "pragma table_info( $table )";

        $result = $this->query( $query );

        // grab all columns
        $columns = [ ];

        foreach ( $result as $res )
        {
            foreach ( $res as $key => $value )
            {
                if ( 'name' === $key && !in_array( $value, $exclude ) )
                {
                    $null = ' NULL';

                    if ( TRUE === ( bool ) $res[ 'notnull' ] )
                    {
                        $null = ' NOT NULL';
                    }

                    $columns[ $value ] = $res[ 'type' ] . $null;
                }
            }
        }

        return $columns;
    }
1342954
public function getMemberDetails()
    {
        if ($user = $this->ChangedBy()) {
            $name = $user->getTitle();
            if ($user->Email) {
                $name .= " <$user->Email>";
            }
            return $name;
        }
    }