Gets the name to use for creating a sequence for a table.

This will create a new name or use one specified in an id-method-parameter
tag, if specified.

@param Table $table

@return string Sequence name for this table.
550125
public function getSequenceName(Table $table)
    {
        static $longNamesMap = array();
        $result = null;
        if ($table->getIdMethod() == IDMethod::NATIVE) {
            $idMethodParams = $table->getIdMethodParameters();
            $maxIdentifierLength = $this->getMaxColumnNameLength();
            if (empty($idMethodParams)) {
                if (strlen($table->getName() . "_SEQ") > $maxIdentifierLength) {
                    if (!isset($longNamesMap[$table->getName()])) {
                        $longNamesMap[$table->getName()] = strval(count($longNamesMap) + 1);
                    }
                    $result = substr($table->getName(), 0, $maxIdentifierLength - strlen("_SEQ_" . $longNamesMap[$table->getName()])) . "_SEQ_" . $longNamesMap[$table->getName()];
                } else {
                    $result = substr($table->getName(), 0, $maxIdentifierLength - 4) . "_SEQ";
                }
            } else {
                $result = substr($idMethodParams[0]->getValue(), 0, $maxIdentifierLength);
            }
        }

        return $result;
    }
858092
protected function resolveTableName($table)
    {
        if (! Str::contains($table, '\\') || ! class_exists($table)) {
            return $table;
        }

        $model = new $table;

        if (! $model instanceof Model) {
            return $table;
        }

        if ($model instanceof Pivot) {
            $this->using($table);
        }

        return $model->getTable();
    }
1344530
public function getPrimaryKeyDDL(Table $table)
    {
        if ($table->hasPrimaryKey() && !$table->hasAutoIncrementPrimaryKey()) {
            return 'PRIMARY KEY (' . $this->getColumnListDDL($table->getPrimaryKey()) . ')';
        }

        return '';
    }
1321082
public function generateClassName($table, $prefix=null, $suffix=null)
    {
        $tableString = '';
        $tableName = explode('_', $table);
        foreach ($tableName as $tableNameExploded) {
            $tableString .= ucfirst($tableNameExploded);
        }
        return ($prefix ? $prefix : '') . ucfirst($tableString) . 'Table' . ($suffix ? $suffix : '') . 'Seeder';
    }
932744
protected function getTableKey($table) {
        if (empty(static::$tableKeys)) {
            $this->loadTableKeys();
        }

        return isset(static::$tableKeys[$table]) ? static::$tableKeys[$table] : static::$tableKeys['__default__'];
    }
672445
private function buildTableName(): string
    {
        $table = '{db_prefix}' . $this->table;
        
        $no_alias_methods = [
            'REPLACE',
            'INSERT'
        ];
        
        if (in_array($this->method, $no_alias_methods)) {
            return $table;
        }
        
        if (! empty($this->alias)) {
            $table .= ' AS ' . $this->alias;
        }
        
        return $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;
    }
845299
protected function getTable($table = '')
    {
        if (empty($table))
        {
            switch (config('auth.driver'))
            {
                case 'eloquent':
                    $table = $this->getTableByModelClass(config('auth.model'));
                    break;
                case 'database':
                default:
                    $table = config('auth.table');
                    break;
            }
        }

        return $table;
    }
410528
protected function resolveTableNames($table,$name)
	{
		$parts=explode('.',str_replace(array('[',']'),'',$name));
		if(($c=count($parts))==3)
		{
			// Catalog name, schema name and table name provided
			$table->catalogName=$parts[0];
			$table->schemaName=$parts[1];
			$table->name=$parts[2];
			$table->rawName=$this->quoteTableName($table->catalogName).'.'.$this->quoteTableName($table->schemaName).'.'.$this->quoteTableName($table->name);
		}
		elseif ($c==2)
		{
			// Only schema name and table name provided
			$table->name=$parts[1];
			$table->schemaName=$parts[0];
			$table->rawName=$this->quoteTableName($table->schemaName).'.'.$this->quoteTableName($table->name);
		}
		else
		{
			// Only the name given, we need to get at least the schema name
			//if (empty($this->_schemaNames)) $this->findTableNames();
			$table->name=$parts[0];
			$table->schemaName=self::DEFAULT_SCHEMA;
			$table->rawName=$this->quoteTableName($table->schemaName).'.'.$this->quoteTableName($table->name);
		}
	}
837112
public function PrefixTable($Table) {
      $Prefix = $this->Database->DatabasePrefix;
      
      if ($Prefix != '' && substr($Table, 0, strlen($Prefix)) != $Prefix)
         $Table = $Prefix.$Table;

      return $Table;
   }
1064907
public function escapeTable(string $table): string
	{
		$segments = [];

		foreach(explode('.', $table) as $segment)
		{
			$segments[] = $this->escapeIdentifier($segment);
		}

		return implode('.', $segments);
	}
1168082
public function FormatTableName($Table) {

      if (strpos($Table, '.') !== FALSE){
         if(preg_match('/^([^\s]+)\s+(?:as\s+)?`?([^`]+)`?$/', $Table, $Matches)){
            $DatabaseTable = '`' . str_replace('.', '`.`', $Matches[1]) . '`';
            $Table = str_replace($Matches[1], $DatabaseTable, $Table);
         }else
            $Table = '`' . str_replace('.', '`.`', $Table) . '`';
      }
      return $Table;
   }
1096588
public function table_simple_name($table, $escaped=false)
  {
    if ( \is_string($table) && ($table = trim($table)) ){
      $mtable = explode(".", str_replace("`", "", $table));
      switch ( \count($mtable) ){
        case 1:
          $table = $mtable[0];
          break;
        case 2:
          $table = $mtable[1];
          break;
        case 3:
          $table = $mtable[1];
          break;
      }
      if ( bbn\str::check_name($table) ){
        return $escaped ? "`".$table."`" : $table;
      }
    }
		return false;
  }
708385
protected function resolveTableNames($table,$name)
	{
		$parts=explode('.',str_replace('"','',$name));
		if(isset($parts[1]))
		{
			$schemaName=$parts[0];
			$tableName=$parts[1];
		}
		else
		{
			$schemaName=self::DEFAULT_SCHEMA;
			$tableName=$parts[0];
		}

		$table->name=$tableName;
		$table->schemaName=$schemaName;
		if($schemaName===self::DEFAULT_SCHEMA)
			$table->rawName=$this->quoteTableName($tableName);
		else
			$table->rawName=$this->quoteTableName($schemaName).'.'.$this->quoteTableName($tableName);
	}
266912
protected function getRealTableName($table)
	{
		$prefix = $this->db->getPrefix();

		// Replace the magic prefix if found.
		$table = preg_replace('|^#__|', $prefix, $table);

		return $table;
	}
1136475
public function getResetSequenceSQL($table) {

        if (is_string($table)) {
            $tablename = $table;
            $xmldb_table = new xmldb_table($tablename);
        } else {
            $tablename = $table->getName();
            $xmldb_table = $table;
        }
        // From http://www.acs.ilstu.edu/docs/oracle/server.101/b10759/statements_2011.htm
        $value = (int)$this->mdb->get_field_sql('SELECT MAX(id) FROM {'.$tablename.'}');
        $value++;

        $seqname = $this->getSequenceFromDB($xmldb_table);

        if (!$seqname) {
            // Fallback, seqname not found, something is wrong. Inform and use the alternative getNameForObject() method
            $seqname = $this->getNameForObject($table, 'id', 'seq');
        }

        return array ("DROP SEQUENCE $seqname",
                      "CREATE SEQUENCE $seqname START WITH $value INCREMENT BY 1 NOMAXVALUE CACHE $this->sequence_cache_size");
    }
1266800
public function renderName(TableStructure $table): string
    {
        if ($this->name === null || is_numeric($this->name)) {
            return "fk-{$table->name}-" . implode('-', $this->columns);
        }

        return $this->name;
    }