本文整理汇总了PHP中Doctrine\DBAL\Schema\Index::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Index::getName方法的具体用法?PHP Index::getName怎么用?PHP Index::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\DBAL\Schema\Index
的用法示例。
在下文中一共展示了Index::getName方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: _addIndex
/**
* Add index to table
*
* @param Index $indexCandidate
* @return Table
*/
protected function _addIndex(Index $indexCandidate)
{
// check for duplicates
foreach ($this->_indexes as $existingIndex) {
if ($indexCandidate->isFullfilledBy($existingIndex)) {
return $this;
}
}
$indexName = $indexCandidate->getName();
$indexName = strtolower($indexName);
if (isset($this->_indexes[$indexName]) || $this->_primaryKeyName != false && $indexCandidate->isPrimary()) {
throw SchemaException::indexAlreadyExists($indexName, $this->_name);
}
// remove overruled indexes
foreach ($this->_indexes as $idxKey => $existingIndex) {
if ($indexCandidate->overrules($existingIndex)) {
unset($this->_indexes[$idxKey]);
}
}
if ($indexCandidate->isPrimary()) {
$this->_primaryKeyName = $indexName;
}
$this->_indexes[$indexName] = $indexCandidate;
return $this;
}
示例4: dropAndCreateIndex
/**
* Drop and create a new index on a table
*
* @param string|Table $table name of the table on which the index is to be created
* @param Index $index
*/
public function dropAndCreateIndex(Index $index, $table)
{
$this->tryMethod('dropIndex', $index->getName(), $table);
$this->createIndex($index, $table);
}
示例5: checkIndex
/**
* Do checks for indexes.
*
* @param Index $index
* @param IgnoredChange $ignoredChange
*
* @return boolean
*/
protected function checkIndex(Index $index, IgnoredChange $ignoredChange)
{
// Not needed to be implemented yet
if ($ignoredChange->getPropertyName() !== $index->getName()) {
return false;
}
return false;
}
示例6: checkIndex
/**
* Do checks for indexes.
*
* @param Index $index
* @param array $alterData
*
* @return boolean
*/
protected function checkIndex(Index $index, array $alterData)
{
// Not needed to be implemented yet
if ($alterData['propertyName'] !== $index->getName()) {
return false;
}
return false;
}
示例7: getCreateIndexSQL
/**
* Gets the SQL to create an index on a table on this platform.
*
* @param Index $index
* @param string|Table $table name of the table on which the index is to be created
* @return string
*/
public function getCreateIndexSQL(Index $index, $table)
{
if ($table instanceof Table) {
$table = $table->getName();
}
$name = $index->getName();
$columns = $index->getColumns();
if (count($columns) == 0) {
throw new \InvalidArgumentException("Incomplete definition. 'columns' required.");
}
$type = '';
if ($index->isUnique()) {
$type = 'UNIQUE ';
}
$query = 'CREATE ' . $type . 'INDEX ' . $name . ' ON ' . $table;
$query .= ' (' . $this->getIndexFieldDeclarationListSQL($columns) . ')';
return $query;
}
示例8: _addIndex
/**
* Adds an index to the table.
*
* @param Index $indexCandidate
*
* @return self
*
* @throws SchemaException
*/
protected function _addIndex(Index $indexCandidate)
{
$indexName = $indexCandidate->getName();
$indexName = $this->normalizeIdentifier($indexName);
$replacedImplicitIndexes = array();
foreach ($this->implicitIndexes as $name => $implicitIndex) {
if ($implicitIndex->isFullfilledBy($indexCandidate) && isset($this->_indexes[$name])) {
$replacedImplicitIndexes[] = $name;
}
}
if (isset($this->_indexes[$indexName]) && !in_array($indexName, $replacedImplicitIndexes, true) || $this->_primaryKeyName != false && $indexCandidate->isPrimary()) {
throw SchemaException::indexAlreadyExists($indexName, $this->_name);
}
foreach ($replacedImplicitIndexes as $name) {
unset($this->_indexes[$name], $this->implicitIndexes[$name]);
}
if ($indexCandidate->isPrimary()) {
$this->_primaryKeyName = $indexName;
}
$this->_indexes[$indexName] = $indexCandidate;
return $this;
}
示例9: 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');
}
}
示例10: 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());
}
示例11: getCreatePrimaryKeySQL
/**
* {@inheritDoc}
*/
public function getCreatePrimaryKeySQL(Index $index, $table)
{
$sql = 'ALTER TABLE ' . $table . ' ADD CONSTRAINT PRIMARY KEY (' . $this->getIndexFieldDeclarationListSQL($index->getQuotedColumns($this)) . ')';
if ($index->getName()) {
$sql .= ' CONSTRAINT ' . $index->getQuotedName($this);
}
return $sql;
}
示例12: 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());
}