Exemplo n.º 1
0
 /**
  * Obtain DBMS specific SQL code portion needed to set an index
  * declaration to be used in statements like CREATE TABLE.
  *
  * @param string $charset       name of the index
  * @param array $definition     index definition
  * @return string  DBMS specific SQL code portion needed to set an index
  * @pacthed by PHPBoost
  * @override
  */
 public function getIndexDeclarationSql($name, array $definition)
 {
     $type = '';
     if (isset($definition['type'])) {
         switch (strtolower($definition['type'])) {
             case 'fulltext':
                 $type = 'FULLTEXT KEY';
                 break;
             case 'unique':
                 $type = 'UNIQUE INDEX';
                 break;
             case 'key':
                 $type = 'KEY';
                 break;
             default:
                 throw DoctrineException::invalidIndexType($definition['type']);
         }
     }
     if (!isset($definition['fields'])) {
         throw DoctrineException::indexFieldsArrayRequired();
     }
     if (!is_array($definition['fields'])) {
         $definition['fields'] = array($definition['fields']);
     }
     $query = $type . ' `' . $name . '`';
     $query .= ' (' . $this->getIndexFieldDeclarationListSql($definition['fields']) . ')';
     return $query;
 }