Returns the columns and attributes given the table name

@param string $table   The name of the table
@param array  $filters Where filters

@return array|false
320068
public function getColumns($table, $filters = null)
    {
        //Argument 1 must be a string
        Argument::i()->test(1, 'string');
        
        $query = $this->utility();
        
        if (is_array($filters)) {
            foreach ($filters as $i => $filter) {
                //array('post_id=%s AND post_title IN %s', 123, array('asd'));
                $format = array_shift($filter);
                $filter = $this->bind($filter);
                $filters[$i] = vsprintf($format, $filter);
            }
        }
        
        $query->showColumns($table, $filters);
        return $this->query($query, $this->getBinds());
    }
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;
	}
378499
public function getColumns($base = false)
    {
        //Get the table name
        $name = $base ? $this->getBase() : $this->getName();

        //Get the columns from the schema
        $columns = $this->getSchema($name)->columns;

        return $this->mapColumns($columns, true);
    }
1181034
public function getDbFields($table, $tablePrefix = null, $filter = 0)
    {
        is_null($tablePrefix) && $tablePrefix = $this->tablePrefix;
        $one = $this->runMongoQuery($tablePrefix . $table, [], ['limit' => 1]);
        return empty($one) ? [] : array_keys($one[0]);
    }
816059
protected function getTableDatabase($table)
    {
        if (!array_key_exists($table, $this->tables)) {
            return false;
        }

        $database = $this->tables[$table];

        # If this table's database depends on the mode
        if (is_array($database)) {
            if (array_key_exists($this->mode, $database)) {
                $database = $database[$this->mode];
            } else {
                $database = $database["default"];
            }
        }

        return $database;
    }
31841
public function filter(Table $table)
    {
        $this->sqlWhere = [];
        $this->sqlParams = [];

        $columns = $table->getColumns();
        foreach ($table->getFilters() as $column => $filters) {
            foreach ($filters as $name => $value) {
                $this->buildFilter($columns[$column]['sql_id'], $columns[$column]['type'], $name, $value);
            }
        }

        if (count($this->sqlWhere) == 0)
            return;

        $ands = [];
        foreach ($this->sqlWhere as $filter => $ors)
            $ands[] = '(' . join(') OR (', $ors) . ')';

        $qb = $this->getQueryBuilder();
        $qb->andWhere('(' . join(') AND (', $ands) .')');
        foreach ($this->sqlParams as $name => $value)
            $qb->setParameter($name, $value);
    }
208612
public function tablesExist($tables)
    {
        if (! is_string($tables) && !is_array($tables)) {
            throw new \InvalidArgumentException(
                'Invalid table name type. Table name must be as string or array',
                E_USER_ERROR
            );
        }

        $tables = $this->prefixTables($tables);
        ! is_array($tables) && $tables = [$tables];
        return $this
            ->getSchemaManager()
            ->tablesExist($tables);
    }
290723
protected function _fetchTableColumns($table)
    {
        $return = array();
        $query  = $this->getObject('lib:database.query.show')
            ->show('FULL COLUMNS')
            ->from($table);

        if($columns = $this->select($query, Database::FETCH_OBJECT_LIST))
        {
            foreach($columns as $column)
            {
                // Set the table name in the raw info (MySQL doesn't add this).
                $column->Table = $table;

                $column = $this->_parseColumnInfo($column, $table);
                $return[$column->name] = $column;
            }
        }

        return $return;
    }
1122593
public function check(Table $table)
    {
        $columns = $table->getColumns();
        foreach ($columns as $id => $params) {
            if (!isset($params['sql_id']))
                throw new \Exception("No 'sql_id' param for ID $id");
        }

        $backupSqlAnds = $this->sqlAnds;
        $backupSqlParams = $this->sqlParams;

        $successfulFilters = [];
        foreach ($table->getFilters() as $column => $filterData) {
            $successfulNames = [];
            foreach ($filterData as $name => $value) {
                if ($this->buildFilter($columns[$column]['sql_id'], $columns[$column]['type'], $name, $value))
                    $successfulNames[$name] = $value;
            }
            if (count($successfulNames) > 0)
                $successfulFilters[$column] = $successfulNames;
        }
        $table->setFilters($successfulFilters);

        $this->sqlAnds = $backupSqlAnds;
        $this->sqlParams = $backupSqlParams;
        return $this;
    }
1158288
public function list_cols($table)
    {
        $q = $this->query('SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = ?',
            array($table));

        if ($q) {
            return $q->fetchAll(PDO::FETCH_COLUMN, 0);
        }

        return array();
    }
608272
public function getFields ($table)
		{
			$sql = "SHOW COLUMNS FROM " . $this->quoteIdentifier($table);

			return $this->query($sql)->fetchColumn('Field');
		}
1135556
final public function columns($table=null) {
      $this->connection();
      $schema = $this->schema ? "{$this->schema}." : '';
      $table  = $table ?: $this->table;
      $table  = explode('.',$table);
      $table  = $table[count($table)-1];



      if($this->driver=='dblib')//FreeTDS
         $sql = "";
      if($this->driver=='4d')
         $sql = "";
      if($this->driver=='pgsql') {
         $schema = $this->schema?  "AND table_schema = '{$this->schema}'":'';
         $sql = "SELECT column_name FROM information_schema.columns WHERE table_name = '{$table}' {$schema};";
      }
      if($this->driver=='sybase')
         $sql = "SELECT sc.name AS column_name FROM syscolumns sc INNER JOIN sysobjects so ON sc.id = so.id WHERE so.name = '{$table}'";
      if($this->driver=='firebird')
         $sql = "SELECT RDB$FIELD_NAME AS column_name FROM RDB$RELATION_FIELDS WHERE RDB$RELATION_NAME='{$table}';";
      if($this->driver=='sqlite')
         $sql = "PRAGMA {$schema}table_info({$table});";
      if($this->driver=='mssql'||$this->driver=='sqlsrv')
         $sql = "SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '{$table}'";
      if($this->driver=='informix')
         $sql = "SELECT colname AS column_name FROM systables AS a JOIN syscolumns AS b ON a.tabid=b.tabid WHERE tabname='{$table}';";
      if($this->driver=='ibm')
         $sql = "DESCRIBE TABLE {$table}";
      if($this->driver=='mysql' || $this->driver=='oci' || $this->driver=='odbc' || $this->driver=='cubrid')
         $sql = "DESCRIBE {$schema}{$table}";

      if($this->driver=='dblib')//FreeTDS
         $field = '';
      if($this->driver=='4d')
         $field = '';
      if($this->driver=='mysql')
         $field = 'Field';
      if($this->driver=='cubrid')
         $field = 'tables_in_demodb';
      if($this->driver=='sqlite')
         $field = 'name';
      if($this->driver=='mssql'||$this->driver=='sqlsrv'||$this->driver=='informix'||$this->driver=='ibm'||$this->driver=='firebird'||$this->driver=='sybase'||$this->driver=='pgsql'||$this->driver=='oci'||$this->driver=='odbc'||$this->driver=='mssql')
         $field = 'column_name';

      try {
         $stmt = $this->id_conn->prepare($sql);
         $stmt->execute();
         $stmt->setFetchMode(constant('\PDO::FETCH_ASSOC'));

         $this->columnsData = [];
         while ($row = $stmt->fetch()) {
            $this->columnsData[] = $row[$field];
         }
      } catch (\PDOException $e) {
         die("Error: " . $e->getMessage() . "<br/>");
      }

      return $this->columnsData;
   }
858921
public function filter($filters)
    {
        $filtered = [];
        foreach ($this->objectArr as $obj) {
            $success = true;
            foreach ($filters as $prop => $value) {
                if ($obj->$prop !== $value) {
                    $success = false;
                    break;
                }
            }
            if ($success) {
                $filtered[] = $obj;
            }
        }
        return $filtered;
    }
61614
public function deleteRows($table, $filters = null)
    {
        Argument::i()
            //Argument 1 must be a string
            ->test(1, 'string')
            //Argument 2 must be a string or array
            ->test(2, 'array', 'string');
        
        $query = $this->delete($table);
        
        //array('post_id=%s AND post_title IN %s', 123, array('asd'));
        if (is_array($filters)) {
            //can be array of arrays
            if (is_array($filters[0])) {
                foreach ($filters as $i => $filter) {
                    if (is_array($filters)) {
                        $format = array_shift($filter);
                        
                        //reindex filters
                        $filter = array_values($filter);
                        
                        //bind filters
                        foreach ($filter as $i => $value) {
                            $filter[$i] = $this->bind($value);
                        }
                        
                        //combine
                        $query->where(vsprintf($format, $filter));
                    }
                }
            } else {
                $format = array_shift($filters);
                
                //reindex filters
                $filters = array_values($filters);
                
                //bind filters
                foreach ($filters as $i => $value) {
                    $filters[$i] = $this->bind($value);
                }
                
                //combine
                $query->where(vsprintf($format, $filters));
            }
        } else {
            $query->where($filters);
        }
        
        //run the query
        $this->query($query, $this->getBinds());
        
        //trigger event
        $this->trigger('sql-delete', $table, $filters);
        
        return $this;
    }
925306
public function getIdActionColumnNames($table)
    {
        $columns = $this->getColumns($table);

        $columns = array_filter($columns, function ($columnName) {
            return strpos($columnName, 'idaction') !== false;
        });

        return array_values($columns);
    }
55935
public function getColumns($table)
    {
        $table = $this->prefixTable($table);

        if (empty($this->queriesResultCache[ 'tableColumns' ][ $table ])) {
            $result = $this->query('PRAGMA TABLE_INFO(' . $this->protectIdentifiers($table, true, null, false) . ')');

            if ($result->count()) {
                foreach ($result as $row) {
                    // Do we know from where to get the column's name?
                    if ( ! isset($key)) {
                        if (isset($row[ 'name' ])) {
                            $key = 'name';
                        }
                    }

                    $this->queriesResultCache[ 'tableColumns' ][ $table ][ $row->offsetGet($key) ] = $row;
                }
            }
        }

        return $this->queriesResultCache[ 'tableColumns' ][ $table ];
    }
879202
private function getColumnNamesFrom($table)
    {
        if (0 === \strpos($table, 'mm_')) {
            $attributes = $this->getAttributeNamesFrom($table);
            \asort($attributes);

            $sql       = $this->translator->trans(
                'tl_metamodel_attribute.tag_column_type.sql',
                [],
                'contao_tl_metamodel_attribute'
            );
            $attribute = $this->translator->trans(
                'tl_metamodel_attribute.tag_column_type.attribute',
                [],
                'contao_tl_metamodel_attribute'
            );

            return [
                $sql       => \array_diff_key(
                    $this->getColumnNamesFromTable($table),
                    \array_flip(\array_keys($attributes))
                ),
                $attribute => $attributes,
            ];
        }

        return $this->getColumnNamesFromTable($table);
    }