Exemplo n.º 1
0
 /**
  * Add index to table
  * 
  * @param Index $index
  * @return Table
  */
 protected function _addIndex(Index $index)
 {
     // check for duplicates
     $c = new Comparator();
     foreach ($this->_indexes as $existingIndex) {
         if ($c->diffIndex($index, $existingIndex) == false) {
             return $this;
         }
     }
     $indexName = $index->getName();
     $indexName = strtolower($indexName);
     if (isset($this->_indexes[$indexName]) || $this->_primaryKeyName != false && $index->isPrimary()) {
         throw SchemaException::indexAlreadyExists($indexName);
     }
     if ($index->isPrimary()) {
         $this->_primaryKeyName = $indexName;
     }
     $this->_indexes[$indexName] = $index;
     return $this;
 }