/** * @param bool $wants_sql * @return bool|string * @throws Ruckusing_Exception */ public function finish($wants_sql = false) { if (!$this->_initialized) { throw new Ruckusing_Exception(sprintf("Table Definition: '%s' has not been initialized", $this->_name), Ruckusing_Exception::INVALID_TABLE_DEFINITION); } 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; if ($this->_auto_generate_id === true) { $this->_primary_keys[] = 'id'; $primary_id = new Ruckusing_Adapter_ColumnDefinition($this->_adapter, 'id', 'primary_key'); $create_table_sql .= $primary_id->to_sql() . ",\n"; } $create_table_sql .= $this->columns_to_str(); $create_table_sql .= $this->keys() . $close_sql; if ($wants_sql) { return $create_table_sql; } else { return $this->_adapter->execute_ddl($create_table_sql); } }