Example #1
0
 /**
  * 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 array $definition     index definition
  * @return string               DBMS specific SQL code portion needed to set an index
  */
 public function getIndexDeclarationSql($name, array $definition)
 {
     $type = '';
     if (isset($definition['type'])) {
         if (strtolower($definition['type']) == 'unique') {
             $type = strtoupper($definition['type']) . ' ';
         } else {
             throw DoctrineException::unknownIndexType($definition['type']);
         }
     }
     if (!isset($definition['fields']) || !is_array($definition['fields'])) {
         throw DoctrineException::indexFieldsArrayRequired();
     }
     $query = $type . 'INDEX ' . $name;
     $query .= ' (' . $this->getIndexFieldDeclarationListSql($definition['fields']) . ')';
     return $query;
 }