Parse column list for SQL drop column statement

@return null|string
498552
protected function _droppedColumnsStatement()
    {
        $columns = $this->_sql->getDroppedColumns();
        if (empty($columns)) {
            return null;
        }

        return implode(', ', array_keys($columns));
    }
250210
public function columns($cols = null)
    {
        deprecationWarning(
            'ValuesExpression::columns() is deprecated. ' .
            'Use ValuesExpression::setColumns()/getColumns() instead.'
        );
        if ($cols !== null) {
            return $this->setColumns($cols);
        }

        return $this->getColumns();
    }
1208658
public function getColumns()
    {
        $rawColumns = substr($this->data, 64, 128);
        $columnsString = rtrim($rawColumns, "\0");
        return explode("\0", $columnsString);
    }
981560
protected function parseSelectStmt(){
		$cols = $this->stmt->getColumns();
		list($source, $where, $group, $order) = $this->clauses;
		foreach($cols as $key => $col){
			$col = preg_match('~^[\w.]+$~', $col) ? ":$col" : $col;
			$cols[$key] = $this->tryDelimite($col);
		}
		$cols = implode(', ', $cols);

		return $this->applyLimit("SELECT $cols\nFROM " . $source . $where . $group . $order);
	}
1078572
public function toString()
    {
        if (!$this->_parts['table']) {
            throw new SqlException("Invalid `DROP TABLE` statement, missing `TABLE` clause.");
        }

        return 'DROP TABLE' .
            $this->_buildFlag('IF EXISTS', $this->_parts['ifExists']) .
            $this->_buildChunk($this->dialect()->names($this->_parts['table'])) .
            $this->_buildFlag('CASCADE', $this->_parts['cascade']) .
            $this->_buildFlag('RESTRICT', $this->_parts['restrict']);
    }
486004
public function loadColumn($index = 0)
    {
        if ($this->stmt === null) {
            return null;
        }

        $columnList = array();
        while ($row = $this->stmt->fetch(\PDO::FETCH_NUM)) {
            $columnList[] = $row[$index];
        }
        return $columnList;
    }
509777
private function parseConnectionError(): array
    {
        $return = ['sql_state' => null, 'code' => null, 'message' => 'Unknown error.'];
        if ($error = error_get_last()) {
            $return['sql_state'] = SqlState::OPPA_CONNECTION_ERROR;

            $errorMessage = strstr($error['message'], "\n", true);
            if ($errorMessage === false) {
                $errorMessage = $error['message'];
            }
            $errorMessage = preg_replace('~(pg_connect\(\)|fatal):\s+~i', '', $errorMessage);
            $errorMessage = explode(':', $errorMessage);
            if (count($errorMessage) > 2) {
                $errorMessage = array_slice($errorMessage, 0, 2);
            }
            $errorMessage = implode(',', $errorMessage);

            $return['message'] = $errorMessage .'.';

            if (strpos($errorMessage, 'to address')) {
                $return['message'] = sprintf('Unable to connect to PostgreSQL server at "%s", '.
                    'could not translate host name "%s" to address.', $this->config['host'], $this->config['host']);
                $return['sql_state'] = SqlState::OPPA_HOST_ERROR;
            } elseif (strpos($errorMessage, 'not exist')) {
                $return['message'] = sprintf('Unable to connect to PostgreSQL server at "%s", '.
                    'database "%s" does not exist.', $this->config['host'], $this->config['name']);
                $return['sql_state'] = SqlState::OPPA_DATABASE_ERROR;
            } elseif (strpos($errorMessage, 'password authentication')) {
                $return['message'] = sprintf('Unable to connect to PostgreSQL server at "%s", '.
                    'password authentication failed for user "%s".', $this->config['host'], $this->config['username']);
                $return['sql_state'] = SqlState::OPPA_AUTHENTICATION_ERROR;
            } elseif (strpos($errorMessage, 'client_encoding')) {
                $return['message'] = sprintf('Unable to connect to PostgreSQL server at "%s", '.
                    'invalid or not-supported character set "%s" given.', $this->config['host'], $this->config['charset']);
                $return['sql_state'] = SqlState::OPPA_CHARSET_ERROR;
            } elseif (strpos($errorMessage, 'TimeZone')) {
                $return['message'] = sprintf('Unable to connect to PostgreSQL server at "%s", '.
                    'invalid or not-supported timezone "%s" given.', $this->config['host'], $this->config['timezone']);
                $return['sql_state'] = SqlState::OPPA_TIMEZONE_ERROR;
            }
        }

        return $return;
    }
470935
protected function _parseConstraints()
    {
        $parts = [];
        foreach ($this->_sql->getConstraints() as $constraint) {
            $cons = $this->_parseConstraint($constraint);
            if ($cons) {
                $parts[] = $cons;
            }
        }
        return implode(', ', $parts);
    }
384227
protected function _droppedConstraintsStatement()
    {
        $columns = $this->_sql->getDroppedConstraints();
        if (empty($columns)) {
            return null;
        }

        return implode(', ', array_keys($columns));
    }
55843
protected function _parseColumns()
    {
        $parts = [];
        foreach ($this->_sql->getColumns() as $column) {
            $parts[] = $this->_parseColumn($column);
        }
        $tableName = $this->_sql->getTable();
        return implode(
            "; ALTER TABLE {$tableName} ADD COLUMN ",
            $parts
        );
    }
910797
private function getSttyColumns()
    {
        if (!function_exists('proc_open')) {
            return null;
        }

        $spec = [
            1 => ['pipe', 'w'],
            2 => ['pipe', 'w'],
        ];

        $process = proc_open('stty -a | grep columns', $spec, $pipes, null, null, ['suppress_errors' => true]);
        if (is_resource($process)) {
            $info = stream_get_contents($pipes[1]);
            fclose($pipes[1]);
            fclose($pipes[2]);
            proc_close($process);

            return $info;
        }

        return null;
    }
514518
public function setToSql(): array
    {
        if (!$this->set) {
            throw new SqlException('Undefined UPDATE SET columns.');
        }

        $sql = $params = [];

        foreach ($this->set as $item) {
            $sqlPart = $item['sql'];

            $item['params'] && $params = array_merge($params, $item['params']);

            $sql[] = $sqlPart;
        }

        $sql = 'SET ' . implode(', ', $sql);

        return [$sql, $params];
    }
868149
protected function parseOrder()
    {
        if (!isset($this->parts['order']) || !is_array($this->parts['order']) || count($this->parts['order']) < 1) {
            return false;
        }

        $orderParts = [];

        foreach ($this->parts['order'] as $itemOrder) {
            if ($itemOrder) {
                if (!is_array($itemOrder)) {
                    $itemOrder = [$itemOrder];
                }

                $column = isset($itemOrder[0]) ? $itemOrder[0] : false;
                $type = isset($itemOrder[1]) ? $itemOrder[1] : '';
                $protected = isset($itemOrder[2]) ? $itemOrder[2] : true;

                $column = ($protected ? $this->protect($column) : $column).' '.strtoupper($type);

                $orderParts[] = trim($column);
            }
        }

        return implode(', ', $orderParts);
    }
717365
protected function _renderColumns($sql)
    {
        if (!count($this->_parts[self::COLUMNS])) {
            return null;
        }

        $columns = array();
        foreach ($this->_parts[self::COLUMNS] as $columnEntry) {
            list($correlationName, $column, $alias) = $columnEntry;
            if ($column instanceof Zend_Db_Expr) {
                $columns[] = $this->_adapter->quoteColumnAs($column, $alias, true);
            } else {
                if ($column == self::SQL_WILDCARD) {
                    $column = new Zend_Db_Expr(self::SQL_WILDCARD);
                    $alias = null;
                }
                if (empty($correlationName)) {
                    $columns[] = $this->_adapter->quoteColumnAs($column, $alias, true);
                } else {
                    $columns[] = $this->_adapter->quoteColumnAs(array($correlationName, $column), $alias, true);
                }
            }
        }

        return $sql .= ' ' . implode(', ', $columns);
    }
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;
   }
123965
public function parse()
    {
        if ($this->query !== null) {
            return $this->query;
        }
        $query = preg_replace_callback('~{(.*?)}~', array($this, 'tableClb'), $this->pattern);
        $pattern = '~\?([a-z\?-]+)?(:([a-z0-9_-]*))?;?~i';
        $callback = array($this, 'placeholderClb');
        $query = preg_replace_callback($pattern, $callback, $query);
        if ((!$this->named) && (count($this->data) > $this->counter)) {
            if (($this->counter > 0) || (isset($this->data[0]))) {
                throw new DataMuch(count($this->data), $this->counter);
            }
        }
        $this->query = $query;
        return $this->query;
    }
435684
public function getColumnQuery() {
        // prepare column types
        $type_val = $this->getTypeVal();
        // build query
        $query = $this->db->quotekey($this->name).' '.$type_val.' '.
            $this->getNullable();
        // unify default for booleans
        if (preg_match('/bool/i', $type_val) && $this->default!==null)
            $this->default = (int) $this->default;
        // default value
        if ($this->default !== false) {
            $def_cmds = array(
                'sqlite2?|mysql|pgsql' => 'DEFAULT',
                'mssql|sybase|dblib|odbc|sqlsrv' => 'constraint DF_'.$this->table->name.'_'.$this->name.' DEFAULT',
                'ibm' => 'WITH DEFAULT',
            );
            $def_cmd = $this->findQuery($def_cmds).' '.$this->getDefault();
            $query .= ' '.$def_cmd;
        }
        if (!empty($this->after) && $this->table instanceof TableModifier) {
            // `after` feature only works for mysql
            if (preg_match('/mysql/', $this->db->driver())) {
                $after_cmd = 'AFTER '.$this->db->quotekey($this->after);
                $query .= ' '.$after_cmd;
            }
        }
        return $query;
    }