Returns a platform-specific query to fetch column data from $Table.

@param string $Table The name of the table to fetch column data from.
346326
public function FetchColumnSql($Table) {
      if ($Table[0] != '`' && !StringBeginsWith($Table, $this->Database->DatabasePrefix))
         $Table = $this->Database->DatabasePrefix.$Table;
      
      return "show columns from ".$this->FormatTableName($Table);
   }
1132666
public function getTableKeys($table)
	{
		// Get the details columns information
		$this->setQuery('SHOW KEYS FROM ' . $this->quoteName($table));
		$keys = $this->loadObjectList('Key_name');

		return $keys;
	}
661186
static function query($table = null)
    {
        $model = new static();
        return $model->newTable($table = null)->asModel(get_class($model));
    }
385756
public function table($table)
    {
        $this->table = $table;
        $alias = $this->alias ?? $this->table;

        if (!in_array('`' . $table . '`.*', $this->select) && !in_array('`' . $alias . '`.*', $this->select)) {
            $this->select[] = '`' . $table . '`.*';
        }

        return $this;
    }
371246
public function table($table)
    {
        if (!isset($this->tables[$table])) {
            $this->tables[$table] = new Table($table, $this->storage);
        }

        return new QueryBuilder($this->tables[$table], $this->filters);
    }
244884
public function getTableColumns(string $table): array
    {
        $schemaTable = self::SCHEMA_COLUMN;

        $where[] = "TABLE_NAME = '{$table}'";
        $where[] = "TABLE_SCHEMA = '{$this->db}'";
        $where   = !empty($where) ? ' WHERE ' . implode(' AND ', $where) : null;

        $querySql = "SELECT `COLUMN_NAME` as `name`,`DATA_TYPE` as `type`,`CHARACTER_MAXIMUM_LENGTH` as `length`,`COLUMN_DEFAULT` as `default` ,`COLUMN_KEY` as `key`,`IS_NULLABLE` as `nullable`,`COLUMN_TYPE` as `column_type`,`COLUMN_COMMENT` as `column_comment` FROM {$schemaTable} {$where}";
        $this->dbHandler->prepare($querySql);
        $this->dbHandler->execute([]);
        $columns = $this->dbHandler->fetch();

        return !empty($columns) ? $columns : [];
    }
1251925
public function columns($table)
	{
		$columns = array();
		$sth = $this->queryColumnInfo($table);

		while (($row = $sth->fetch())) {
			$c = $this->createColumn($row);
			$columns[$c->name] = $c;
		}
		return $columns;
	}
463758
protected function fetchColumnDefsDb(string $table) {
        $cdefs = $this->query('pragma table_info('.$this->prefixTable($table, false).')')->fetchAll(PDO::FETCH_ASSOC);
        if (empty($cdefs)) {
            return null;
        }

        $columns = [];
        $pk = [];
        foreach ($cdefs as $cdef) {
            $column = Db::typeDef($cdef['type']);
            if ($column === null) {
                throw new \Exception("Unknown type '$columnType'.", 500);
            }
            $column['allowNull'] = !filter_var($cdef['notnull'], FILTER_VALIDATE_BOOLEAN);

            if ($cdef['pk']) {
                $pk[] = $cdef['name'];
                if (strcasecmp($cdef['type'], 'integer') === 0) {
                    $column['autoIncrement'] = true;
                } else {
                    $column['primary'] = true;
                }
            }
            if ($cdef['dflt_value'] !== null) {
                $column['default'] = $this->forceType($cdef['dflt_value'], $column['type']);
            }
            $columns[$cdef['name']] = $column;
        }
//        $tdef = ['columns' => $columns];
//        if (!empty($pk)) {
//            $tdef['indexes'][Db::INDEX_PK] = [
//                'columns' => $pk,
//                'type' => Db::INDEX_PK
//            ];
//        }
//        $this->tables[$table] = $tdef;
        return $columns;
    }
710517
final public function describe($table)
	{
		$q = $this->query("DESCRIBE `{$table}`");
		$q->execute();
		return $q->fetchAll(self::FETCH_COLUMN);
	}
1201980
public function getCreateTable(string $table): string
	{
		return (string) $this->context->query('SHOW CREATE TABLE ' . $table)->fetch()->{'Create Table'};
	}
932744
protected function getTableKey($table) {
        if (empty(static::$tableKeys)) {
            $this->loadTableKeys();
        }

        return isset(static::$tableKeys[$table]) ? static::$tableKeys[$table] : static::$tableKeys['__default__'];
    }
341537
final public function fetchColumnDefs(string $table) {
        $tableKey = strtolower($table);

        if (!empty($this->tables[$tableKey]['columns'])) {
            $this->tables[$tableKey]['columns'];
        } elseif ($this->tableNames !== null && !isset($this->tableNames[$tableKey])) {
            return null;
        }

        $columnDefs = $this->fetchColumnDefsDb($table);
        if ($columnDefs !== null) {
            $this->tables[$tableKey]['columns'] = $columnDefs;
        }
        return $columnDefs;
    }
350994
public function get_columns($table) {
		$result = $this->get_table_definition($table);

		$columns = [];
		foreach ($result as $row) {
			$columns[] = &$row['Field'];
		}

		return $columns;
	}
1303842
protected function requiredTableColumns($table)
    {
        // If the DBSCHEMA is not set, try using the database name if provided with the table.
        if (! $this->params['DBSCHEMA']) {
            preg_match('/(.*)\./', $table, $db);

            if (isset($db[1])) {
                $this->params['DBSCHEMA'] = $db[1];
            }
        }

        // Parse out the table name.
        $table = preg_replace('/(.*\.)/', '', $table);
        $table = trim($table, '`');

        // Statement to extract all required columns for a table.
        $sqlStatement = "
            SELECT 
                column_name, data_type 
            FROM 
                information_schema.columns 
            WHERE 
                is_nullable = 'NO'
            AND 
                table_name = '%s'
            AND 
                table_schema = '%s';";

        // Get not null columns
        $sql = sprintf(
            $sqlStatement,
            $table,
            $this->params['DBSCHEMA']
        );

        $statement = $this->execute($sql);
        $this->throwExceptionIfErrors($statement);
        $result = $statement->fetchAll();

        if (! $result) {
            return [];
        }

        $cols = [];
        foreach ($result as $column) {
            $cols[$column['column_name']] = $column['data_type'];
        }

        // Dont populate primary key, let db handle that
        unset($cols['id']);

        return $cols;
    }
1119800
public static function allFrom(Table $table) : Select
    {
        $select = new Select($table);

        foreach ($table->getColumnNames() as $columnNames) {
            $select->addRawColumn($columnNames);
        }

        return $select;
    }
83931
public function getColumns($table)
    {
        //Argument 1 must be a string
        Argument::i()->test(1, 'string');
        
        $query = $this->utility()->showColumns($table);
        $results = $this->query($query, $this->getBinds());
        
        $columns = array();
        foreach ($results as $column) {
            $key = null;
            if ($column['pk'] == 1) {
                $key = 'PRI';
            }
            
            $columns[] = array(
                'Field'     => $column['name'],
                'Type'      => $column['type'],
                'Default'   => $column['dflt_value'],
                'Null'      => $column['notnull'] != 1,
                'Key'       => $key);
        }
        
        return $columns;
    }
1265341
private static function _get_table_where(string $table): ?string
  {
    if (
      bbn\str::check_name($table) &&
      ($db = self::_get_db()) &&
      ($databases_obj = self::_get_databases()) &&
      ($model = $databases_obj->modelize($table))
    ){
      $col = $db->escape('col');
      $where_ar = [];
      foreach ( $model['fields'] as $k => $f ){
        if ( !empty($f['id_option']) ){
          $where_ar[] = $col.' = UNHEX("'.$db->escape_value($f['id_option']).'")';
        }
      }
      if ( \count($where_ar) ){
        return implode(' OR ', $where_ar);
      }
    }
    return null;
  }