/** * Add an index to a database table. * * In $options you can specific unique = true/false or name (index name). * * @param string|array|Index $columns Table Column(s) * @param array $options Index Options * @return Table */ public function addIndex($columns, $options = array()) { // create a new index object if strings or an array of strings were supplied if (!$columns instanceof Index) { $index = new Index(); if (is_string($columns)) { $columns = array($columns); // str to array } $index->setColumns($columns); $index->setOptions($options); } else { $index = $columns; } $this->indexes[] = $index; return $this; }
/** * Sets the index columns. * * @param array $columns * * @return $this */ public function setColumns(array $columns) { $this->index->setColumns($columns); return $this; }