Esempio n. 1
0
 /**
  * Creates index object from tokens.
  * <p>
  * And registers index in the table index registry.
  *
  * @param Tokenizer $tokenizer Tokens collection.
  * @param boolean $unique Uniqueness flag.
  * @param string $indexName Optional name of the index.
  *
  * @return Table
  * @see Index::create
  */
 public function createIndex(Tokenizer $tokenizer, $unique = false, $indexName = '')
 {
     $index = Index::create($tokenizer, $unique, $indexName);
     $index->setParent($this);
     $this->indexes->add($index);
     return $this;
 }
Esempio n. 2
0
 /**
  * @param Tokenizer $tokenizer Statement tokens.
  * @param boolean $unique Index uniqueness flag.
  *
  * @return void
  * @throws NotSupportedException
  */
 protected function executeCreateIndex(Tokenizer $tokenizer, $unique)
 {
     $tokenizer->skipWhiteSpace();
     $tokenizer->setBookmark();
     Index::searchTableName($tokenizer);
     $tableName = $tokenizer->getCurrentToken()->text;
     /** @var Table $table */
     $table = $this->tables->search($tableName);
     if (!$table) {
         throw new NotSupportedException("Table [{$tableName}] not found. line: " . $tokenizer->getCurrentToken()->line);
     }
     $tokenizer->restoreBookmark();
     $table->createIndex($tokenizer, $unique);
 }