public function column_definition($column_name, $type, $options = null) { $col = new Ruckusing_ColumnDefinition($this, $column_name, $type, $options); return $col->__toString(); }
public function finish($wants_sql = false) { if ($this->initialized == false) { throw new Ruckusing_InvalidTableDefinitionException(sprintf("Table Definition: '%s' has not been initialized", $this->name)); } if (is_array($this->options) && array_key_exists('options', $this->options)) { $opt_str = $this->options['options']; } else { $opt_str = null; } $close_sql = sprintf(") %s;", $opt_str); $create_table_sql = $this->sql . $this->columns_to_str(); if ($this->auto_generate_id === true) { $this->primary_keys[] = 'id'; $primary_id = new Ruckusing_ColumnDefinition($this->adapter, 'id', 'integer', array('unsigned' => true, 'null' => false, 'auto_increment' => true)); $create_table_sql .= ",\n" . $primary_id->to_sql(); } $create_table_sql .= $this->keys() . $close_sql; if ($wants_sql) { return $create_table_sql; } else { return $this->adapter->execute_ddl($create_table_sql); } }