add_index() public method

Add an index
public add_index ( string $table_name, string $column_name, array $options = [] ) : boolean
$table_name string the table name
$column_name string the column name
$options array index options
return boolean
 /**
  * test remove index with custom index name
  */
 public function test_remove_index_with_custom_index_name()
 {
     //create it
     $table = $this->adapter->create_table('users');
     $table->column('name', 'string', array('limit' => 20));
     $table->column('age', 'integer');
     $table->finish();
     $this->adapter->add_index("users", "name", array('name' => 'my_special_index'));
     $this->assertEquals(true, $this->adapter->has_index("users", "name", array('name' => 'my_special_index')));
     //drop it
     $this->adapter->remove_index("users", "name", array('name' => 'my_special_index'));
     $this->assertEquals(false, $this->adapter->has_index("users", "name", array('name' => 'my_special_index')));
     $this->drop_table('users');
 }
Beispiel #2
0
 /**
  * Add an index
  *
  * @param string $table_name the name of the table
  * @param string $column_name the column name
  * @param array|string $options
  *
  * @return boolean
  */
 public function add_index($table_name, $column_name, $options = array())
 {
     return $this->_adapter->add_index($table_name, $column_name, $options);
 }