Ruckusing_Adapter_MySQL_TableDefinition::column PHP Method

column() public method

Create a column
public column ( string $column_name, string $type, array $options = [] )
$column_name string the column name
$type string the column type
$options array
    public function column($column_name, $type, $options = array())
    {
        //if there is already a column by the same name then silently fail
        //and continue
        if ($this->_table_def->included($column_name) == true) {
            return;
        }
        $column_options = array();
        if (array_key_exists('primary_key', $options)) {
            if ($options['primary_key'] == true) {
                $this->_primary_keys[] = $column_name;
            }
        }
        if (array_key_exists('auto_increment', $options)) {
            if ($options['auto_increment'] == true) {
                $column_options['auto_increment'] = true;
            }
        }
        $column_options = array_merge($column_options, $options);
        $column = new Ruckusing_Adapter_ColumnDefinition($this->_adapter, $column_name, $type, $column_options);
        $this->_columns[] = $column;
    }

Usage Example

 /**
  * test that we can generate a table w/o a primary key
  */
 public function test_generate_table_without_primary_key()
 {
     $t1 = new Ruckusing_Adapter_MySQL_TableDefinition($this->adapter, "users", array('id' => false, 'options' => 'Engine=InnoDB'));
     $t1->column("first_name", "string");
     $t1->column("last_name", "string", array('limit' => 32));
     $actual = $t1->finish();
     $col = $this->adapter->column_info("users", "id");
     $this->assertEquals(null, $col);
 }
All Usage Examples Of Ruckusing_Adapter_MySQL_TableDefinition::column