示例#1
0
 /**
  * Builds the DDL SQL to add an Index.
  *
  * @param  Index  $index
  * @return string
  */
 public function getAddIndexDDL(Index $index)
 {
     // don't create index form primary key
     if ($this->getPrimaryKeyName($index->getTable()) == $this->quoteIdentifier($index->getName())) {
         return "";
     }
     $pattern = "\r\nCREATE %sINDEX %s ON %s (%s)%s;\r\n";
     return sprintf($pattern, $index->getIsUnique() ? 'UNIQUE ' : '', $this->quoteIdentifier($index->getName()), $this->quoteIdentifier($index->getTable()->getName()), $this->getColumnListDDL($index->getColumns()), $this->generateBlockStorage($index));
 }
 protected function getIndexType(Index $index)
 {
     $type = '';
     $vendorInfo = $index->getVendorInfoForType($this->getDatabaseType());
     if ($vendorInfo && $vendorInfo->getParameter('Index_type')) {
         $type = $vendorInfo->getParameter('Index_type') . ' ';
     } elseif ($index->getIsUnique()) {
         $type = 'UNIQUE ';
     }
     return $type;
 }
示例#3
0
 /**
  * Builds the DDL SQL for an Index object.
  *
  * @param      Index $index
  * @return     string
  */
 public function getIndexDDL(Index $index)
 {
     return sprintf('%sINDEX %s (%s)', $index->getIsUnique() ? 'UNIQUE ' : '', $this->quoteIdentifier($index->getName()), $this->getColumnListDDL($index->getColumns()));
 }