Add and put index to `code` column
Use if identity an item alternatively to ID
@param $tableName
7050
public function addCode($tableName, $columnName = 'code')
    {
        $this->addColumn('{{%' . $tableName . '}}', $columnName,
            $this->string(32)->comment('Code for this item, used identifying when needed. Another criteria to replace ID because ID is auto-increment'));
        $this->createIndex($tableName . '_' . $columnName . '_idx', '{{%' . $tableName . '}}', $columnName);
    }
593207
protected function addRelationChild($tableName) {
		$parameter = new ParameterGenerator();
		$parameter->setName('whereArray');
		$parameter->setDefaultValue([]);
		
		$child = new NameManager($this->getNames()->namespace, $tableName);
		
		// METHOD:getRelationChild
		$functionName = ucwords($tableName); 
		$method = $this->buildMethod("gather{$functionName}");
		$method->setParameter($parameter);
		$body = <<<MBODY
if (!is_array(\$whereArray)) {
	\$whereArray = [];
}
\$where = array_merge(['fk_{$this->getNames()->tableName}' => \$this->{$this->getNames()->primary}], \$whereArray);
\${$child->tableName} = new \\{$child->namespace_model}\\{$child->modelName}();
return \${$child->tableName}->select(\$where);
MBODY;
		$method->setBody($body);
		$tag = new ReturnTag();
		$tag->setTypes("\\Zend\\Db\\ResultSet\\HydratingResultSet");
		$docBlock = new DocBlockGenerator();
		$docBlock->setTag(new ParamTag('whereArray', ['datatype'  => []]));
		$docBlock->setTag($tag);
		$docBlock->setShortDescription("Related {$child->entityName}");
		$method->setDocBlock($docBlock);
		$this->_class->addMethodFromGenerator($method);
	}
221979
def insertInto(self, tableName, overwrite=False):
        
        self._jwrite.mode("overwrite" if overwrite else "append").insertInto(tableName)
456859
public function getIndexByName($indexName, $tableName)
    {
        $indices = $this->getIndices($tableName);

        $result = null;

        foreach ($indices as $index) {
            if ($indexName === $index['Column_name']) {
                $result = $index;
            }
        }

        return $result;
    }
1004294
public function addOrderingWeight($tableName)
    {
        $this->addColumn('{{%' . $tableName . '}}', 'ordering_weight',
            $this->bigInteger()->defaultValue(0)->comment('An extra index for custom sorting'));
        $this->createIndex($tableName . '_ordering_weight' . '_idx', '{{%' . $tableName . '}}', 'ordering_weight');
    }
431971
public function handle(string $tableName)
    {
        /** @var RecordFinder $recordFinder */
        $recordFinder = GeneralUtility::makeInstance(RecordFinder::class);

        // tx_styleguide_staticdata is used in other TCA demo fields. We need some default
        // rows to later connect other fields to these rows.
        $pid = $recordFinder->findPidOfMainTableRecord('tx_styleguide_staticdata');
        $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('tx_styleguide_staticdata');
        $connection->bulkInsert(
            'tx_styleguide_staticdata',
            [
                [ $pid, 'foo' ],
                [ $pid, 'bar' ],
                [ $pid, 'foofoo' ],
                [ $pid, 'foobar' ],
            ],
            [ 'pid', 'value_1' ]
        );
    }
1266476
public function createIndex($indexName, $tableName, $columns)
    {
        
        $sql = 'CREATE INDEX ' . $indexName . ' ON ' . $tableName . ' (';
        $colsSql = array();
        foreach ($columns as $n => $l){
            // $n = name, $l = length
            if (!empty($l)){
                $colsSql[] =  $n . '(' . $l . ')';
            }
            else{
                $colsSql[] =  $n ;
            }
        }
    
        $colsSql = implode(',', $colsSql);
        $sql .= $colsSql . ')';
    
        $this->getDriver()->exec($sql);
        
    }
921171
void addValue(String columnName, String value)
    {
        addValue(columnNames.indexOf(columnName), value);
    }
278006
protected function addIndexes(Table $table)
    {
        $stmt = $this->dbh->query(sprintf('SHOW INDEX FROM %s', $this->getPlatform()->doQuoting($table->getName())));

        // Loop through the returned results, grouping the same key_name together
        // adding each column for that key.

        /** @var $indexes Index[] */
        $indexes = [];
        while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
            $colName = $row['Column_name'];
            $colSize = $row['Sub_part'];
            $name = $row['Key_name'];

            if ('PRIMARY' === $name) {
                continue;
            }

            if (!isset($indexes[$name])) {
                $isUnique = (0 == $row['Non_unique']);
                if ($isUnique) {
                    $indexes[$name] = new Unique($name);
                } else {
                    $indexes[$name] = new Index($name);
                }
                if ($this->addVendorInfo) {
                    $vi = $this->getNewVendorInfoObject($row);
                    $indexes[$name]->addVendorInfo($vi);
                }
                $indexes[$name]->setTable($table);
            }

            $indexes[$name]->addColumn([
                'name' => $colName,
                'size' => $colSize
            ]);
        }

        foreach ($indexes as $index) {
            if ($index instanceof Unique) {
                $table->addUnique($index);
            } else {
                $table->addIndex($index);
            }
        }
    }
945246
private function getAddedColumns($tableName, TableDiff $diff)
    {
        /** @var $col \Doctrine\DBAL\Schema\Column */
        foreach ($diff->addedColumns as $col) {
            $this->addMessage($tableName, sprintf('missing column `%s`', $col->getName()));
        }
    }
502077
protected function addDatabasePrefix($tableName, $addDatabaseName = true)
    {
        return ($addDatabaseName && $this->_sourceData['gso_ls_database'] ? $this->_sourceData['gso_ls_database'] . '.' : '') .
            $this->_sourceData['gso_ls_table_prefix'] .
            $tableName;
    }
1213802
private function putRowInIndex(&$index, $metadataNamesToIndexBy, $row, $idSite, $period)
    {
        $currentLevel = & $index;

        foreach ($metadataNamesToIndexBy as $metadataName) {
            if ($metadataName == DataTableFactory::TABLE_METADATA_SITE_INDEX) {
                $key = $idSite;
            } elseif ($metadataName == DataTableFactory::TABLE_METADATA_PERIOD_INDEX) {
                $key = $period;
            } else {
                $key = $row[self::METADATA_CONTAINER_ROW_KEY][$metadataName];
            }

            if (!isset($currentLevel[$key])) {
                $currentLevel[$key] = array();
            }

            $currentLevel = & $currentLevel[$key];
        }

        $currentLevel = $row;
    }
565814
protected function addIndexes(Table $table)
	{
		return;
		$stmt = $this->dbh->query("SHOW INDEX FROM `" . $table->getName() . "`");

		// Loop through the returned results, grouping the same key_name together
		// adding each column for that key.

		$indexes = array();
		while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
			$colName = $row["Column_name"];
			$name = $row["Key_name"];

			if ($name == "PRIMARY") {
				continue;
			}

			if (!isset($indexes[$name])) {
				$isUnique = ($row["Non_unique"] == 0);
				if ($isUnique) {
					$indexes[$name] = new Unique($name);
				} else {
					$indexes[$name] = new Index($name);
				}
				if ($this->addVendorInfo) {
					$vi = $this->getNewVendorInfoObject($row);
					$indexes[$name]->addVendorInfo($vi);
				}
				$table->addIndex($indexes[$name]);
			}

			$indexes[$name]->addColumn($table->getColumn($colName));
		}
	}
574904
public function addTable($tableName)
    {
        $this->tables[$tableName] = new TableMap($tableName, $this);

        return $this->tables[$tableName];
    }
268370
protected function addIndexes(Table $table)
    {
        $stmt = $this->dbh->query("SELECT INDEX_NAME, COLUMN_NAME FROM USER_IND_COLUMNS WHERE TABLE_NAME = '" . $table->getName() . "' ORDER BY COLUMN_NAME");

        $indices = [];
        while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
            $indices[$row['INDEX_NAME']][]= $row['COLUMN_NAME'];
        }

        foreach ($indices as $indexName => $columnNames) {
            $index = new Index($indexName);
            foreach ($columnNames as $columnName) {
                // Oracle deals with complex indices using an internal reference, so...
                // let's ignore this kind of index
                if ($table->hasColumn($columnName)) {
                    $index->addColumn($table->getColumn($columnName));
                }
            }
            // since some of the columns are pruned above, we must only add an index if it has columns
            if ($index->hasColumns()) {
                $table->addIndex($index);
            }
        }
    }
685747
function replace(string $tableName, array $values)
  {
    $v = $this->makeClauses($values);
    $this->q
    (
      "replace `$tableName` set ".
      implode(",",$v)
    );
    return $this->insert_id;
  }
700460
public function addCreatedDate($tableName, $columnName = 'created_date_gmt')
    {
        $this->addColumn('{{%' . $tableName . '}}', $columnName,
            $this->dateTime()->comment('Date and time this record created (in GMT)'));
        $this->createIndex($tableName . '_' . $columnName . '_idx', '{{%' . $tableName . '}}', $columnName);
    }