rename_column() public method

Rename a column
public rename_column ( string $table_name, string $column_name, string $new_column_name ) : boolean
$table_name string the table name
$column_name string the column name
$new_column_name string the new column name
return boolean
 /**
  * test renaming column
  */
 public function test_rename_column()
 {
     $this->adapter->drop_table('users');
     //create it
     $table = $this->adapter->create_table('users');
     $table->column('name', 'string', array('limit' => 20));
     $table->finish();
     $before = $this->adapter->column_info("users", "name");
     $this->assertEquals('character varying(20)', $before['type']);
     $this->assertEquals('name', $before['field']);
     //rename the name column
     $this->adapter->rename_column('users', 'name', 'new_name');
     $after = $this->adapter->column_info("users", "new_name");
     $this->assertEquals('character varying(20)', $after['type']);
     $this->assertEquals('new_name', $after['field']);
     $this->drop_table('users');
 }
Ejemplo n.º 2
0
 /**
  * Rename a column
  *
  * @param string $tbl_name        the name of the table
  * @param string $column_name     the column name
  * @param string $new_column_name the new column name
  *
  * @return boolean
  */
 public function rename_column($tbl_name, $column_name, $new_column_name)
 {
     return $this->_adapter->rename_column($tbl_name, $column_name, $new_column_name);
 }