/**
  * Utility method that maps an array of index options to this objects methods.
  *
  * @param array $options Options
  *
  * @throws \RuntimeException
  * @return $this
  */
 public function setOptions(array $options)
 {
     $this->index->setOptions($options);
     return $this;
 }
Esempio n. 2
0
 /**
  * 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;
 }
Esempio n. 3
0
 /**
  * @expectedException \RuntimeException
  * @expectedExceptionMessage "0" is not a valid index option.
  */
 public function testSetOptionThrowsExceptionIfOptionIsNotString()
 {
     $column = new Index();
     $column->setOptions(['type']);
 }