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 $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;
 }
Example #2
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;
 }