本文整理汇总了PHP中Doctrine\DBAL\Schema\Index::getColumns方法的典型用法代码示例。如果您正苦于以下问题:PHP Index::getColumns方法的具体用法?PHP Index::getColumns怎么用?PHP Index::getColumns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\DBAL\Schema\Index
的用法示例。
在下文中一共展示了Index::getColumns方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexToArray
/**
* @param string $table
* @param \Doctrine\DBAL\Schema\Index $index
* @return array
*/
protected function indexToArray($table, $index)
{
if ($index->isPrimary()) {
$type = 'primary';
} elseif ($index->isUnique()) {
$type = 'unique';
} else {
$type = 'index';
}
$array = ['type' => $type, 'name' => null, 'columns' => $index->getColumns()];
if (!$this->isDefaultIndexName($table, $index->getName(), $type, $index->getColumns())) {
$array['name'] = $index->getName();
}
return $array;
}
示例2: indexToArray
/**
* @param string $table
* @param \Doctrine\DBAL\Schema\Index $index
* @return array
*/
protected function indexToArray($table, $index)
{
if ($index->isPrimary()) {
$type = 'primary';
} elseif ($index->isUnique()) {
$type = 'unique';
} else {
$type = 'index';
}
$array = ['type' => $type, 'name' => null, 'columns' => $index->getColumns()];
if (!$this->ignoreIndexNames and !$this->isDefaultIndexName($table, $index->getName(), $type, $index->getColumns())) {
// Sent Index name to exclude spaces
$array['name'] = str_replace(' ', '', $index->getName());
}
return $array;
}
示例3: populatePrimaryKey
/**
* Populates a primary key based on a index.
*
* @param Attrs $attrs
* @param Index $index
*/
private function populatePrimaryKey($attrs, $index)
{
if (!$index->isPrimary()) {
return;
}
$columns = $index->getColumns();
$key = current($columns);
// We don't support composite primary keys quite yet.
if (count($columns) > 1) {
return;
}
$attrs->set($this->deriveName($key), ['key' => $key, 'type' => 'primary']);
}
示例4: getCreateSpatialIndexSQL
/**
* Generates the sql to create a spatial index.
*
* @param SpatialIndex $index
* @param Table | string $table
* @return string The sql to create a spatial index on the database.
* @throws \InvalidArgumentException
*/
public function getCreateSpatialIndexSQL(Index $index, $table)
{
if ($table instanceof Table) {
$table = $table->getQuotedName($this);
}
$name = $index->getQuotedName($this);
$columns = $index->getColumns();
if (count($columns) == 0) {
throw new \InvalidArgumentException("Incomplete definition. 'columns' required.");
}
$query = 'CREATE INDEX ' . $name . ' ON ' . $table;
$query .= ' USING GIST (' . $this->getIndexFieldDeclarationListSQL($columns) . ')';
return $query;
}
示例5: overrules
/**
* Detect if the other index is a non-unique, non primary index that can be overwritten by this one.
*
* @param Index $other
* @return bool
*/
public function overrules(Index $other)
{
if ($other->isPrimary()) {
return false;
} else {
if ($this->isSimpleIndex() && $other->isUnique()) {
return false;
}
}
if ($this->spansColumns($other->getColumns()) && ($this->isPrimary() || $this->isUnique())) {
return true;
}
return false;
}
示例6: getIndexDeclarationSQL
/**
* Obtain DBMS specific SQL code portion needed to set an index
* declaration to be used in statements like CREATE TABLE.
*
* @param string $name name of the index
* @param Index $index index definition
* @return string DBMS specific SQL code portion needed to set an index
*/
public function getIndexDeclarationSQL($name, Index $index)
{
$type = '';
if ($index->isUnique()) {
$type = 'UNIQUE ';
}
if (count($index->getColumns()) == 0) {
throw \InvalidArgumentException("Incomplete definition. 'columns' required.");
}
return $type . 'INDEX ' . $name . ' (' . $this->getIndexFieldDeclarationListSQL($index->getColumns()) . ')';
}
示例7: _appendUniqueConstraintDefinition
/**
* Extend unique key constraint with required filters
*
* @param string $sql
* @param Index $index
* @return string
*/
private function _appendUniqueConstraintDefinition($sql, Index $index)
{
$fields = array();
foreach ($index->getColumns() as $field => $definition) {
if (!is_array($definition)) {
$field = $definition;
}
$fields[] = $field . ' IS NOT NULL';
}
return $sql . ' WHERE ' . implode(' AND ', $fields);
}
示例8: getPreAlterTableAlterPrimaryKeySQL
/**
* @param TableDiff $diff
* @param Index $index
*
* @return string[]
*/
private function getPreAlterTableAlterPrimaryKeySQL(TableDiff $diff, Index $index)
{
$sql = array();
if (!$index->isPrimary() || !$diff->fromTable instanceof Table) {
return $sql;
}
$tableName = $diff->getName($this)->getQuotedName($this);
// Dropping primary keys requires to unset autoincrement attribute on the particular column first.
foreach ($index->getColumns() as $columnName) {
$column = $diff->fromTable->getColumn($columnName);
if ($column->getAutoincrement() === true) {
$column->setAutoincrement(false);
$sql[] = 'ALTER TABLE ' . $tableName . ' MODIFY ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray());
// original autoincrement information might be needed later on by other parts of the table alteration
$column->setAutoincrement(true);
}
}
return $sql;
}
示例9: checkIndex
/**
* @param Table $table
* @param Index $index
* @param Migration $migration
*
* @throws InvalidNameException
*/
protected function checkIndex(Table $table, Index $index, Migration $migration)
{
$columns = $index->getColumns();
foreach ($columns as $columnName) {
if ($table->getColumn($columnName)->getLength() > MySqlPlatform::LENGTH_LIMIT_TINYTEXT) {
throw new InvalidNameException(sprintf('Could not create index for column with length more than %s. ' . 'Please correct "%s" column length "%s" in table in "%s" migration', MySqlPlatform::LENGTH_LIMIT_TINYTEXT, $columnName, $table->getName(), get_class($migration)));
}
}
}
示例10: intersectsIndexColumns
/**
* Checks whether this foreign key constraint intersects the given index columns.
*
* Returns `true` if at least one of this foreign key's local columns
* matches one of the given index's columns, `false` otherwise.
*
* @param Index $index The index to be checked against.
*
* @return boolean
*/
public function intersectsIndexColumns(Index $index)
{
foreach ($index->getColumns() as $indexColumn) {
foreach ($this->_localColumnNames as $localColumn) {
if (strtolower($indexColumn) === strtolower($localColumn->getName())) {
return true;
}
}
}
return false;
}
示例11: getIndexDeclarationSQL
/**
* Obtain DBMS specific SQL code portion needed to set an index
* declaration to be used in statements like CREATE TABLE.
*
* @param string $name name of the index
* @param Index $index index definition
*
* @return string DBMS specific SQL code portion needed to set an index
*/
public function getIndexDeclarationSQL($name, Index $index)
{
if (count($index->getColumns()) === 0) {
throw new \InvalidArgumentException("Incomplete definition. 'columns' required.");
}
return $this->getCreateIndexSQLFlags($index) . 'INDEX ' . $name . ' (' . $this->getIndexFieldDeclarationListSQL($index->getColumns()) . ')';
}
示例12: saveIndex
/**
* @param Index $index
* @param \SimpleXMLElement $xml
*/
private static function saveIndex($index, $xml)
{
$xml->addChild('name', $index->getName());
if ($index->isPrimary()) {
$xml->addChild('primary', 'true');
} elseif ($index->isUnique()) {
$xml->addChild('unique', 'true');
}
foreach ($index->getColumns() as $column) {
$field = $xml->addChild('field');
$field->addChild('name', $column);
$field->addChild('sorting', 'ascending');
}
}
示例13: createIndexReplacement
/**
* Creates a index replacement, which has quoted names.
*
* @param Index $index
*
* @return Index
*/
private function createIndexReplacement(Index $index)
{
return new Index($this->platform->quoteIdentifier($index->getName()), $this->quoteIdentifiers($index->getColumns()), $index->isUnique(), $index->isPrimary(), $index->getFlags(), $index->getOptions());
}
示例14: acceptIndex
/**
* Accept an index on in a table
*
* @param Table $table a table object
* @param Index $index a column object
*
* @return void
*/
public function acceptIndex(Table $table, Index $index)
{
$this->schemaArray['tables'][$table->getName()]['indexes'][$index->getName()] = array('name' => $index->getName(), 'columns' => $index->getColumns(), 'unique' => $index->isUnique(), 'primary' => $index->isPrimary());
}