Guess the cols with the guesser

@param  string           $table
@param  array            $cols
@param  GuesserInterface $guesser
@return array
424906
protected function guessColsAnonType(string $table, array $cols, GuesserInterface $guesser): array
    {
        $mapping = [];
        foreach ($cols as $props) {
            $mapping[$props['name']] = $guesser->mapCol($table, $props['name'], $props['type'], $props['len']);
        }

        return $mapping;
    }
330127
public function FetchColumns($Table) {
      $Sql = $this->FetchColumnSql($Table);
      $Data = $this->Query($Sql);
      $Return = array();
      foreach($Data->ResultArray() as $Row) {
         if (isset($Row['COLUMN_NAME']))
            $Return[] = $Row['COLUMN_NAME'];
         else
            $Return[] = current($Row);
      }

      return $Return;
   }
609834
public function getColumns($table)
    {
        $table = str_replace("`", "", $table);

        $columns = Db::fetchAll("SHOW COLUMNS FROM `" . $table . "`");

        $columnNames = array();
        foreach ($columns as $column) {
            $columnNames[] = $column['Field'];
        }

        return $columnNames;
    }
435778
public function into($table, array $columns = [])
    {
        if (count($columns)) {
            $this->setColumns($columns);
        }

        return $this->addRootTable($table);
    }
907707
protected function getCreateColumnCommentsSQLQueries(array $columns, $table)
    {
        $queries = array();

        foreach ($columns as $column) {
            if ($this->hasCustomType($column->getType()->getName()) || ($column->getComment() !== null)) {
                $queries[] = $this->getCreateColumnCommentSQLQuery($column, $table);
            }
        }

        return $queries;
    }
1265773
public function getPrimaryKeys($table)
    {
        $pk = [];
        $cols = $this->getColumns($table);
        if ($cols) {
            foreach ($cols as $key => $val){
                if(isset($val['is_primary']) && $val['is_primary']) {
                    $pk[] = $key;
                }
            }
        }
        
        return $pk;
    }
677046
public function withColumnsButIgnoringConstraints(array $columns) : Table
    {
        if ($this->columns === $columns) {
            return $this;
        }

        return new self($this->name, $columns);
    }
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);
   }
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;
    }
1080747
private function _getColumns($table)
    {
        if (isset($this->_tables[$table])) {
            return $this->_tables[$table];
        };
        $this->_tables[$table] = false;
        if ($rows = $this->selectArray("PRAGMA table_info({$table})")) {
            $cols = array();
            foreach ($rows as $row) {
                $cols[] = $row['name'];
            };
            if (count($cols) > 0) {
                $this->_tables[$table] = $cols;
            };
        };
        return $this->_tables[$table];
    }
1286633
public function findModelInstancesBy(string $table, $columns, $values, array $options = [])
    {
        /* @var Model $adapter */
        if (!($modelClass = $this->framework->getAdapter(Model::class)->getClassFromTable($table))) {
            return null;
        }

        if (null === ($adapter = $this->framework->getAdapter($modelClass))) {
            return null;
        }

        $this->fixTablePrefixForDcMultilingual($table, $columns, $options);

        if (\is_array($values) && (!isset($options['skipReplaceInsertTags']) || !$options['skipReplaceInsertTags'])) {
            $values = array_map('\Contao\Controller::replaceInsertTags', $values);
        }

        if (empty($columns)) {
            $columns = null;
        }

        return $adapter->findBy($columns, $values, $options);
    }
925914
public function table(Table\Table $table)
    {

        // Headers
        $head = '';
        $headers = [];
        $hasStrainer = false;
        foreach($table->getColumns() as $column) {
            /** @var Column\Column $column */
			$label = $column->getLabel();
			if ($column->hasDescription()) {
				$label .= ' <i class="fa fa-question-circle" data-toggle="tooltip" title="'.$column->getDescription().'"></i>';
			}
            $head .= html('th', ['class' => 'text-center'], $label);
            $headers[] = $column->getName();
            $hasStrainer = $hasStrainer || $column->hasStrainer();
        }

        $head = html('tr', ['class' => 'heading'], $head);


        // Strainer
        if ($hasStrainer) {

            // initialisation des strainer
            $strainer = '';
            foreach($table->getColumns() as $column) {
                /** @var Column\Column $column */
                $content = '';
                if ($column->hasStrainer()) {
                    $content = $column->getStrainer()->render();
                }

                $strainer .= html('th', ['class' => 'text-center'],$content);
            }

            $head .= html('tr', ['class' => 'filter'], $strainer);
        }

        // Data
        $body = '';
        foreach($table->getRows() as $row) {

            $line = '';
            foreach($table->getColumns() as $name => $column) {

                $attributes = $column->getAttributes();
                if ($table->hasIdField()) {

                    if (!isset($row[$table->getIdField()])) {
                        throw new \LogicException($table->getIdField() . ' column is not found');
                    }

                    //too soon for you
//                  $attributes['data-id'] = sprintf('%s#%s', $row[$table->getIdField()], $name);
                }

                // remove class in colum because it set in column for datatable
                if ($table->isDatatable()) {
                    unset($attributes['class']);
                }

                $line .= html('td', $attributes, $column->render((array) $row)) . PHP_EOL;
            }

            $body .= html('tr', [],$line );
        }

		// Footer
		$footer = '';

        if ($table->isDatatable()) {
            $this->render('datatable', $table);
        } elseif ($table->hasFooter()) {
			$current = $table->getPage();
			$footer .= sprintf('<li class="disabled"><span>&laquo;</span></li>');
			for ($i = 1; $i <= min(10, $table->getPagesTotal()); $i++) {
				$footer .= html('li', ['class' => $current == $i ? 'active' : null], sprintf('<a href="%s">%s</a>', $table->getPageUrl($i), $i));
			}

			$footer .= sprintf('<li><a href="%s" rel="next">&raquo;</a></li>', '#');
			$footer = html('ul', ['class' => 'pagination'], $footer);
			$footer = html('td', ['colspan' => count($headers)], $footer);
			$footer = html('tr', [], $footer);
			$footer = html('tfoot', ['class' => 'text-center'], $footer);
		}


        // Bootstrap class management
        $table->addClass(Style::TABLE_CLASS);

        if ($table->isStriped()){
            $table->addClass(Style::TABLE_CLASS_STRIPED);
        }

        if ($table->isBordered()) {
            $table->addClass(Style::TABLE_CLASS_BORDERED);
        }

        if ($table->isCondensed()) {
            $table->addClass(Style::TABLE_CLASS_CONDENSED);
        }

        if ($table->hasHover()) {
            $table->addClass(Style::TABLE_CLASS_HOVER);
        }


        $html =  html('table', $table->getAttributes(), html('thead', [], $head) . html('tbody', [], $body) . $footer);

        // responsive
        if ($table->isResponsive()){
            $html = html('div', ['class' => Style::TABLE_CLASS_RESPONSIVE], $html);
        }

        if ($table->hasPanel()) {
            $html = $table->getPanel()->setBody($html)->render();
        }

        return $html;
    }
433266
public function createTable(Table $table)
    {
        if (!$table->hasOption('charset') && !$table->hasOption('collate')) {
            $connParams = $this->_conn->getParams();
            if (isset($connParams['defaultTableOptions']['charset']) && isset($connParams['defaultTableOptions']['collate'])) {
                $table
                    ->addOption('charset', $connParams['defaultTableOptions']['charset'])
                    ->addOption('collate', $connParams['defaultTableOptions']['collate'])
                ;
            }
        }

        return parent::createTable($table);
    }
183066
public static function build(Table $table, array $columns = [])
    {
        $index = new Index();
        $index->setColumns($columns);

        return new static($table, $index);
    }
383822
public function getColumnTypes($resultSet, $table){
		if($table === null)
			return array();
		if(isset($this->tblData[$table]))
			$sql = $this->tblData[$table];
		else
			$q = $this->runQuery("SELECT sql FROM sqlite_master WHERE tbl_name='$table'");
		$r = $this->fetch($q);
		if($r === false)
			return array();
		$this->tblData[$table] = $sql = $r['sql'];
		$sql = explode("\n", $sql);

		$cols = array();
		foreach($sql as $field){
			$field = trim($field);
			preg_match('~^"(\w+)"\s+(integer|real|numeric|text|blob).+$~i', $field, $m);
			if(isset($m[1], $m[2]))
				$cols[$m[1]] = $m[2];
		}
		return $cols;
	}
1012313
public function random_value($col, $table){
    $val = null;
    if ( ($tab = $this->modelize($table)) && isset($tab['fields'][$col]) ){
      foreach ( $tab['keys'] as $key => $cfg ){
        if (
          $cfg['unique'] &&
          !empty($cfg['ref_column']) &&
          (\count($cfg['columns']) === 1) &&
          ($col === $cfg['columns'][0])
        ){
          return ($num = $this->count($cfg['ref_column'])) ? $this->select_one([
            'tables' [$cfg['ref_table']],
            'fields' => [$cfg['ref_column']],
            'start' => random_int(0, $num - 1)
          ]) : null;
        }
      }
      switch ( $tab['fields'][$col]['type'] ){
        case 'int':
          if ( ($tab['fields'][$col]['maxlength'] === 1) && !$tab['fields'][$col]['signed'] ){
            $val = microtime(true) % 2 === 0 ? 1 : 0;
          }
          else {
            $max = 10 ** $tab['fields'][$col]['maxlength'] - 1;
            if ( $max > mt_getrandmax() ){
              $max = mt_getrandmax();
            }
            if ( $tab['fields'][$col]['signed'] ){
              $max /= 2;
            }
            $min = $tab['fields'][$col]['signed'] ? -$max : 0;
            $val = random_int($min, $max);
          }
          break;
        case 'float':
        case 'double':
        case 'decimal':
          break;
        case 'varchar':
          break;
        case 'text':
          break;
        case 'date':
          break;
        case 'datetime':
          break;
        case 'timestamp':
          break;
        case 'time':
          break;
        case 'year':
          break;
        case 'blob':
          break;
        case 'binary':
          break;
        case 'varbinary':
          break;
        case 'enum':
          break;
      }
    }
    return $val;
  }
732230
public function getColumnTypes($resultSet, $table){
		if($table === null)
			return array();
		$cols = pg_meta_data($this->resource, $table);
		foreach($cols as $key => $value){
			$cols[$key] = preg_replace('~[^a-z]~i', '', $value['type']);
		}
		return $cols;
	}