Returns the SQL statements to drop the autoincrement for the given table name.

@param string $table The table name to drop the autoincrement for.

@return string[]
353676
public function getDropAutoincrementSql($table)
    {
        $table                       = $this->normalizeIdentifier($table);
        $autoincrementIdentifierName = $this->getAutoincrementIdentifierName($table);
        $identitySequenceName        = $this->getIdentitySequenceName(
            $table->isQuoted() ? $table->getQuotedName($this) : $table->getName(),
            ''
        );

        return [
            'DROP TRIGGER ' . $autoincrementIdentifierName,
            $this->getDropSequenceSQL($identitySequenceName),
            $this->getDropConstraintSQL($autoincrementIdentifierName, $table->getQuotedName($this)),
        ];
    }
883283
public function getResetSequenceSQL($table) {

        if ($table instanceof xmldb_table) {
            $tablename = $table->getName();
        } else {
            $tablename = $table;
        }

        // From http://dev.mysql.com/doc/refman/5.0/en/alter-table.html
        $value = (int)$this->mdb->get_field_sql('SELECT MAX(id) FROM {'.$tablename.'}');
        $value++;
        return array("ALTER TABLE $this->prefix$tablename AUTO_INCREMENT = $value");
    }
1193121
protected function generateColumns($table): array
    {
        $columns = $table->getColumns();
        $result  = [
            'columns'          => [],
            'hasSoftDelete'    => false,
            'hasRememberToken' => false,
        ];
        foreach ($columns as $column) {
            if ($column->getName() === 'id') {
                continue;
            }
            if (($column->getName() === 'created_at' || $column->getName() === 'updated_at') and ($column->getType() === 'timestamp' || $column->getType() === 'timestamp_f')) {
                continue;
            }
            if ($column->getName() === 'deleted_at' and ($column->getType() === 'timestamp' || $column->getType() === 'timestamp_f')) {
                $result['hasSoftDelete'] = true;
                continue;
            }
            if ($column->getName() === 'remember_token' and $column->getType() === 'varchar') {
                $result['hasRememberToken'] = true;
                continue;
            }

            $columnObject = new Column($column);
            $line         = $columnObject->generateAddMigration();

            $result['columns'][] = $line.';';
        }

        return $result;
    }
605805
public function listTableIndexes($table)
    {
        $sql = $this->_platform->getListTableIndexesSQL($table, $this->_conn->getDatabase());

        $tableIndexes = $this->_conn->fetchAll($sql);

        return $this->_getPortableTableIndexesList($tableIndexes, $table);
    }
1354070
public function get_indexes($table) {
        $indexes = array ();
        $tablename = $this->prefix.$table;

        // Indexes aren't covered by information_schema metatables, so we need to
        // go to sys ones. Skipping primary key indexes on purpose.
        $sql = "SELECT i.name AS index_name, i.is_unique, ic.index_column_id, c.name AS column_name
                  FROM sys.indexes i
                  JOIN sys.index_columns ic ON i.object_id = ic.object_id AND i.index_id = ic.index_id
                  JOIN sys.columns c ON ic.object_id = c.object_id AND ic.column_id = c.column_id
                  JOIN sys.tables t ON i.object_id = t.object_id
                 WHERE t.name = '$tablename' AND i.is_primary_key = 0
              ORDER BY i.name, i.index_id, ic.index_column_id";

        $this->query_start($sql, null, SQL_QUERY_AUX);
        $result = sqlsrv_query($this->sqlsrv, $sql);
        $this->query_end($result);

        if ($result) {
            $lastindex = '';
            $unique = false;
            $columns = array ();

            while ($row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC)) {
                if ($lastindex and $lastindex != $row['index_name'])
                    { // Save lastindex to $indexes and reset info
                    $indexes[$lastindex] = array
                     (
                      'unique' => $unique,
                      'columns' => $columns
                     );

                    $unique = false;
                    $columns = array ();
                }
                $lastindex = $row['index_name'];
                $unique = empty($row['is_unique']) ? false : true;
                $columns[] = $row['column_name'];
            }

            if ($lastindex) { // Add the last one if exists
                $indexes[$lastindex] = array
                 (
                  'unique' => $unique,
                  'columns' => $columns
                 );
            }

            $this->free_result($result);
        }
        return $indexes;
    }
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];
    }
738561
public function getTableSequences($table)
    {
        // To check if table exists and prevent SQL injection
        $tableList = $this->db->getDatabase()->getTables();

        if (in_array($table, $tableList)) {
            $name = [
                's.relname AS sequence',
                'n.nspname AS schema',
                't.relname AS table',
                'a.attname AS column',
                'info.data_type AS data_type',
                'info.minimum_value AS minimum_value',
                'info.maximum_value AS maximum_value',
                'info.increment AS increment',
                'info.cycle_option AS cycle_option',
            ];

            if (version_compare($this->db->getVersion(), '9.1.0') >= 0) {
                $name[] .= 'info.start_value AS start_value';
            }

            // Get the details columns information.
            $query = $this->db->getQuery(true);

            $query->select($this->db->quoteName($name))
                ->from('pg_class AS s')
                ->leftJoin(
                    "pg_depend d ON d.objid=s.oid AND d.classid='pg_class'::regclass "
                    . "AND d.refclassid='pg_class'::regclass"
                )
                ->leftJoin('pg_class t ON t.oid=d.refobjid')
                ->leftJoin('pg_namespace n ON n.oid=t.relnamespace')
                ->leftJoin('pg_attribute a ON a.attrelid=t.oid AND a.attnum=d.refobjsubid')
                ->leftJoin('information_schema.sequences AS info ON info.sequence_name=s.relname')
                ->where("s.relkind='S' AND d.deptype='a' AND t.relname=" . $this->db->quote($table));

            $this->db->setQuery($query);

            $seq = $this->db->loadAll();

            return $seq;
        }

        return false;
    }
307837
public function getAliasNames($table) {
    $names = [];
    if (is_array($this->table) && current($this->table) == $table) {
      $names[] = key($this->table);
    }
    foreach ($this->joins->getJoins() as $join) {
      $joinName = $join['name'];
      if (is_array($joinName) && current($joinName) == $table) {
        $names[] = key($joinName);
      }
    }
    return $names;
  }
1310436
public function getTableNames($sql) {
        $sql = trim(strtoupper($sql));

        if (strpos($sql, 'SELECT') === 0) {
            return $this->express($sql, static::$selectExpression);
        } else if (strpos($sql, 'UPDATE') === 0) {
            return $this->express($sql, static::$updateExpression);
        } else if (strpos($sql, 'INSERT') === 0) {
            return $this->express($sql, static::$insertExpression);
        } else if (strpos($sql, 'DELETE') === 0) {
            return $this->express($sql, static::$deleteExpression);
        }
        return [];
    }
42493
protected function getAlternatePrimaryKeys($table)
    {
        $alternatePrimaryKey = false;
        $primaryKeys = [];
        foreach ($table['columns'] as $column) {
            $columnName = $column['COLUMN_NAME'];
            $columnKey = $column['COLUMN_KEY'];
            if ($columnKey !== 'PRI') {
                continue;
            }
            if ($columnName !== 'id') {
                $alternatePrimaryKey = true;
            }
            $primaryKeys[] = '"' . $columnName . '"';
        }
        if ($alternatePrimaryKey) {
            return $primaryKeys;
        }

        return null;
    }
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;
    }
1073471
protected function findColumns($table)
	{
		$sql='SHOW FULL COLUMNS FROM '.$table->rawName;
		try
		{
			$columns=$this->getDbConnection()->createCommand($sql)->queryAll();
		}
		catch(Exception $e)
		{
			return false;
		}
		foreach($columns as $column)
		{
			$c=$this->createColumn($column);
			$table->columns[$c->name]=$c;
			if($c->isPrimaryKey)
			{
				if($table->primaryKey===null)
					$table->primaryKey=$c->name;
				elseif(is_string($table->primaryKey))
					$table->primaryKey=array($table->primaryKey,$c->name);
				else
					$table->primaryKey[]=$c->name;
				if($c->autoIncrement)
					$table->sequenceName='';
			}
		}
		return true;
	}
913313
protected function getCreateTable($table)
    {
        $db = $this->db;

        $result = $db->getReader('SHOW CREATE TABLE ' . $this->db->quoteName($table))->loadArray();

        $sql = preg_replace('#AUTO_INCREMENT=\S+#is', '', $result[1]);

        $sql = explode("\n", $sql);

        $tableStriped = TableHelper::stripPrefix($result[0], $db->getPrefix());

        $sql[0] = str_replace($result[0], $tableStriped, $sql[0]);

        $sql = implode("\n", $sql);

        return $sql;
    }
12011
public function drop($table = '')
    {
        $tableName = '';

        $tableName = ($table !== '') ?
            $table : $this->tableName;

        $this->schema = strtoupper(__FUNCTION__).' TABLE IF EXISTS
        `'.$this->database.'`.`'.$tableName.'`'.PHP_EOL;

        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);
    }
750403
public function get_fields(string $table = ''): ?array
  {
    if ( !empty($this->class_cfg) ){
      if ( $table ){
        return $this->class_cfg['arch'][$table] ?? null;
      }
      return $this->class_cfg['arch'];
    }
    return null;
  }
499095
private function getFields($table)
    {
        $fields = $this->entity->getFieldNames();
        if (empty($this->with) && $this->alias === null) {
            return $fields;
        }

        $table = $this->getTableAlias($table);

        $prefixIfMissing = function ($field) use ($table) {
            if (strpos($field, '.') !== false) {
                return $field;
            }

            return $table . '.' . $field;
        };

        return array_map($prefixIfMissing, $fields);
    }