/** * @param CreateTable $schema * * @return string */ protected function handleIndexKeys(CreateTable $schema) { $indexes = $schema->getIndexes(); if (empty($indexes)) { return array(); } $sql = array(); $table = $schema->getTableName(); foreach ($indexes as $name => $columns) { $sql[] = 'CREATE INDEX ' . $this->wrap($table . '_' . $name) . ' ON ' . $this->wrap($table) . '(' . $this->wrapArray($columns) . ')'; } return $sql; }
/** * @param CreateTable $schema * * @return array */ public function create(CreateTable $schema) { $sql = 'CREATE TABLE ' . $this->wrap($schema->getTableName()); $sql .= "(\n"; $sql .= $this->handleColumns($schema->getColumns()); $sql .= $this->handlePrimaryKey($schema); $sql .= $this->handleUniqueKeys($schema); $sql .= $this->handleForeignKeys($schema); $sql .= "\n)" . $this->handleEngine($schema); $commands = array(); $commands[] = array('sql' => $sql, 'params' => $this->getParams()); foreach ($this->handleIndexKeys($schema) as $index) { $commands[] = array('sql' => $index, 'params' => array()); } return $commands; }