Exemple #1
0
 /**
  * Gets the SqlServer Index Definition for an Index object.
  *
  * @param Index $index Index
  * @return string
  */
 protected function getIndexSqlDefinition(Index $index, $tableName)
 {
     if (is_string($index->getName())) {
         $indexName = $index->getName();
     } else {
         $columnNames = $index->getColumns();
         if (is_string($columnNames)) {
             $columnNames = array($columnNames);
         }
         $indexName = sprintf('%s_%s', $tableName, implode('_', $columnNames));
     }
     $def = sprintf("CREATE %s INDEX %s ON %s (%s);", $index->getType() === Index::UNIQUE ? 'UNIQUE' : '', $indexName, $this->quoteTableName($tableName), '[' . implode('],[', $index->getColumns()) . ']');
     return $def;
 }
Exemple #2
0
 /**
  * Gets the MySQL Index Definition for an Index object.
  *
  * @param Index $index Index
  * @return string
  */
 protected function getIndexSqlDefinition(Index $index)
 {
     $def = '';
     $limit = '';
     if ($index->getLimit()) {
         $limit = '(' . $index->getLimit() . ')';
     }
     if ($index->getType() == Index::UNIQUE) {
         $def .= ' UNIQUE';
     }
     if ($index->getType() == Index::FULLTEXT) {
         $def .= ' FULLTEXT';
     }
     $def .= ' KEY';
     if (is_string($index->getName())) {
         $def .= ' `' . $index->getName() . '`';
     }
     $def .= ' (`' . implode('`,`', $index->getColumns()) . '`' . $limit . ')';
     return $def;
 }
 /**
  * Gets the PostgreSQL Index Definition for an Index object.
  *
  * @param Index  $index Index
  * @param string $tableName Table name
  * @return string
  */
 protected function getIndexSqlDefinition(Index $index, $tableName)
 {
     $def = sprintf("CREATE %s INDEX %s ON %s (%s);", $index->getType() == Index::UNIQUE ? 'UNIQUE' : '', $this->getIndexName($tableName, $index->getColumns()), $this->quoteTableName($tableName), implode(',', $index->getColumns()));
     return $def;
 }
 /**
  * Gets the MySQL Index Definition for an Index object.
  *
  * @param Index $index Index
  * @return string
  */
 protected function getIndexSqlDefinition(Index $index)
 {
     $def = '';
     if ($index->getType() == Index::UNIQUE) {
         $def .= ' UNIQUE KEY (`' . implode('`,`', $index->getColumns()) . '`)';
     } else {
         $def .= ' KEY (`' . implode('`,`', $index->getColumns()) . '`)';
     }
     return $def;
 }
Exemple #5
0
 /**
  * Gets the SQLite Index Definition for an Index object.
  *
  * @param Index $index Index
  * @return string
  */
 protected function getIndexSqlDefinition(Table $table, Index $index)
 {
     if ($index->getType() == Index::UNIQUE) {
         $def = 'UNIQUE INDEX';
     } else {
         $def = 'INDEX';
     }
     if (is_string($index->getName())) {
         $indexName = $index->getName();
     } else {
         $indexName = $table->getName() . '_';
         foreach ($index->getColumns() as $column) {
             $indexName .= $column . '_';
         }
         $indexName .= 'index';
     }
     $def .= ' `' . $indexName . '`';
     return $def;
 }
 /**
  * Gets the index dbType.
  *
  * @return string
  */
 public function getType()
 {
     return $this->index->getType();
 }