libglom-1.20 1.20.6
Typedefs | Functions
Glom::DbUtils Namespace Reference

Typedefs

typedef std::vector< sharedptr
< Field > > 
type_vec_fields
typedef std::vector
< Glib::ustring
type_vec_strings

Functions

bool create_database (Document* document, const Glib::ustring& database_name, const Glib::ustring& title, const sigc::slot< void >& progress)
bool recreate_database_from_document (Document* document, const sigc::slot< void >& progress)
 Create the database on an already-connected server.
SystemPrefs get_database_preferences (Document* document)
 This creates the standard tables if necessary, filling them with some information from the document.
void set_database_preferences (Document* document, const SystemPrefs& prefs)
bool add_standard_tables (Document* document)
bool add_standard_groups (Document* document)
bool add_groups_from_document (Document* document)
bool set_table_privileges_groups_from_document (Document* document)
type_vec_fields get_fields_for_table_from_database (const Glib::ustring& table_name, bool including_system_fields=false)
bool get_field_exists_in_database (const Glib::ustring& table_name, const Glib::ustring& field_name)
type_vec_strings get_table_names_from_database (bool ignore_system_tables=false)
bool get_table_exists_in_database (const Glib::ustring& table_name)
bool create_table (const sharedptr< const TableInfo >& table_info, const Document::type_vec_fields& fields)
bool create_table_with_default_fields (Document* document, const Glib::ustring& table_name)
 Also saves the table information in the document:
bool create_table_add_missing_fields (const sharedptr< const TableInfo >& table_info, const Document::type_vec_fields& fields)
bool add_column (const Glib::ustring& table_name, const sharedptr< const Field >& field, Gtk::Window* parent_window)
bool drop_column (const Glib::ustring& table_name, const Glib::ustring& field_name)
bool insert_example_data (Document* document, const Glib::ustring& table_name)
Glib::RefPtr
< Gnome::Gda::DataModel > 
query_execute_select (const Glib::RefPtr< const Gnome::Gda::SqlBuilder >& builder, bool use_cursor=false)
 Execute a SQL Select command, returning the result.
bool query_execute_string (const Glib::ustring& strQuery, const Glib::RefPtr< Gnome::Gda::Set >& params=Glib::RefPtr< Gnome::Gda::Set >(0))
 Execute a SQL non-select command, returning true if it succeeded.
bool query_execute (const Glib::RefPtr< const Gnome::Gda::SqlBuilder >& builder)
 Execute a SQL non-select command, returning true if it succeeded.
Gnome::Gda::Value auto_increment_insert_first_if_necessary (const Glib::ustring& table_name, const Glib::ustring& field_name)
Gnome::Gda::Value get_next_auto_increment_value (const Glib::ustring& table_name, const Glib::ustring& field_name)
 Get the next auto-increment value for this primary key, from the glom system table.
void remove_auto_increment (const Glib::ustring& table_name, const Glib::ustring& field_name)
 Use this, for instance, when deleting a table.
void layout_item_fill_field_details (Document* document, const Glib::ustring& parent_table_name, sharedptr< LayoutItem_Field >& layout_item)
bool layout_field_should_have_navigation (const Glib::ustring& table_name, const sharedptr< const LayoutItem_Field >& layout_item, const Document* document, sharedptr< Relationship >& field_used_in_relationship_to_one)
 Decides whether a field should have an Open button next to it, allowing the user to navigate to a related record.
Glib::ustring get_unused_database_name (const Glib::ustring& base_name)
 Discover a database name that is not yet used.
int count_rows_returned_by (const Glib::RefPtr< const Gnome::Gda::SqlBuilder >& sql_query)
 Discover how many rows a SQL query would return if it was run.
bool rename_table (const Glib::ustring& table_name, const Glib::ustring& new_table_name)
 Rename a table in the database.
bool drop_table (const Glib::ustring& table_name)
Glib::ustring escape_sql_id (const Glib::ustring& id)
 Escape, and quote, SQL identifiers such as table names.
Glib::ustring gda_cnc_string_encode (const Glib::ustring& str)
 Just a wrapper around gda_rfc1738_encode(), for use when building libgda connection strings or authentication strings.
Glib::ustring build_query_create_group (const Glib::ustring& group, bool superuser=false)
Glib::ustring build_query_add_user_to_group (const Glib::ustring& group, const Glib::ustring& user)
void set_fake_connection ()
 Allow a fake connection, so sqlbuilder_get_full_query() can work.

Typedef Documentation


Function Documentation

bool Glom::DbUtils::add_column ( const Glib::ustring table_name,
const sharedptr< const Field > &  field,
Gtk::Window *  parent_window 
)
bool Glom::DbUtils::add_groups_from_document ( Document *  document)
bool Glom::DbUtils::add_standard_groups ( Document *  document)
bool Glom::DbUtils::add_standard_tables ( Document *  document)
Gnome::Gda::Value Glom::DbUtils::auto_increment_insert_first_if_necessary ( const Glib::ustring table_name,
const Glib::ustring field_name 
)
Glib::ustring Glom::DbUtils::build_query_add_user_to_group ( const Glib::ustring group,
const Glib::ustring user 
)
Glib::ustring Glom::DbUtils::build_query_create_group ( const Glib::ustring group,
bool  superuser = false 
)
int Glom::DbUtils::count_rows_returned_by ( const Glib::RefPtr< const Gnome::Gda::SqlBuilder > &  sql_query)

Discover how many rows a SQL query would return if it was run.

This uses a COUNT * on a the sql_query as a sub-statement. Be careful not to include ORDER BY clauses in the supplied SQL query, because that would make it unnecessarily slow.

A SQL query.

Returns:
The number of rows. Or -1 if something went wrong.
bool Glom::DbUtils::create_database ( Document *  document,
const Glib::ustring database_name,
const Glib::ustring title,
const sigc::slot< void > &  progress 
)
bool Glom::DbUtils::create_table ( const sharedptr< const TableInfo > &  table_info,
const Document::type_vec_fields &  fields 
)
bool Glom::DbUtils::create_table_add_missing_fields ( const sharedptr< const TableInfo > &  table_info,
const Document::type_vec_fields &  fields 
)
bool Glom::DbUtils::create_table_with_default_fields ( Document *  document,
const Glib::ustring table_name 
)

Also saves the table information in the document:

bool Glom::DbUtils::drop_column ( const Glib::ustring table_name,
const Glib::ustring field_name 
)
bool Glom::DbUtils::drop_table ( const Glib::ustring table_name)
Glib::ustring Glom::DbUtils::escape_sql_id ( const Glib::ustring id)

Escape, and quote, SQL identifiers such as table names.

Glib::ustring Glom::DbUtils::gda_cnc_string_encode ( const Glib::ustring str)

Just a wrapper around gda_rfc1738_encode(), for use when building libgda connection strings or authentication strings.

SystemPrefs Glom::DbUtils::get_database_preferences ( Document *  document)

This creates the standard tables if necessary, filling them with some information from the document.

bool Glom::DbUtils::get_field_exists_in_database ( const Glib::ustring table_name,
const Glib::ustring field_name 
)
type_vec_fields Glom::DbUtils::get_fields_for_table_from_database ( const Glib::ustring table_name,
bool  including_system_fields = false 
)
Gnome::Gda::Value Glom::DbUtils::get_next_auto_increment_value ( const Glib::ustring table_name,
const Glib::ustring field_name 
)

Get the next auto-increment value for this primary key, from the glom system table.

Add a row for this field in the system table if it does not exist already.

bool Glom::DbUtils::get_table_exists_in_database ( const Glib::ustring table_name)
type_vec_strings Glom::DbUtils::get_table_names_from_database ( bool  ignore_system_tables = false)
Glib::ustring Glom::DbUtils::get_unused_database_name ( const Glib::ustring base_name)

Discover a database name that is not yet used.

This assumes that all other connection details are correctly set.

Parameters:
base_nameThe wished-for name, to be modified until an unused name is found.
Returns:
A database name that does not yet exist on the server.
bool Glom::DbUtils::insert_example_data ( Document *  document,
const Glib::ustring table_name 
)
bool Glom::DbUtils::layout_field_should_have_navigation ( const Glib::ustring table_name,
const sharedptr< const LayoutItem_Field > &  layout_item,
const Document *  document,
sharedptr< Relationship > &  field_used_in_relationship_to_one 
)

Decides whether a field should have an Open button next to it, allowing the user to navigate to a related record.

Parameters:
layout_itemA field on a layout. This must have full field details.
field_used_in_relationship_to_oneA relationship, if the field identifies a single record, so a Find button would also make sense, to choose the ID, in editing mode.
void Glom::DbUtils::layout_item_fill_field_details ( Document *  document,
const Glib::ustring parent_table_name,
sharedptr< LayoutItem_Field > &  layout_item 
)
bool Glom::DbUtils::query_execute ( const Glib::RefPtr< const Gnome::Gda::SqlBuilder > &  builder)

Execute a SQL non-select command, returning true if it succeeded.

Glib::RefPtr<Gnome::Gda::DataModel> Glom::DbUtils::query_execute_select ( const Glib::RefPtr< const Gnome::Gda::SqlBuilder > &  builder,
bool  use_cursor = false 
)

Execute a SQL Select command, returning the result.

Parameters:
builderThe finished SqlBuilder object. Whether the data model should be cursor-based (not allowing random access).
bool Glom::DbUtils::query_execute_string ( const Glib::ustring strQuery,
const Glib::RefPtr< Gnome::Gda::Set > &  params = Glib::RefPtr< Gnome::Gda::Set >(0) 
)

Execute a SQL non-select command, returning true if it succeeded.

See also query_execute(), which takes a SqlBuilder. This should only be used for SQL commands that are not supported by SqlBuilder, such as ADD GROUP.

bool Glom::DbUtils::recreate_database_from_document ( Document *  document,
const sigc::slot< void > &  progress 
)

Create the database on an already-connected server.

void Glom::DbUtils::remove_auto_increment ( const Glib::ustring table_name,
const Glib::ustring field_name 
)

Use this, for instance, when deleting a table.

bool Glom::DbUtils::rename_table ( const Glib::ustring table_name,
const Glib::ustring new_table_name 
)

Rename a table in the database.

void Glom::DbUtils::set_database_preferences ( Document *  document,
const SystemPrefs &  prefs 
)
void Glom::DbUtils::set_fake_connection ( )

Allow a fake connection, so sqlbuilder_get_full_query() can work.

bool Glom::DbUtils::set_table_privileges_groups_from_document ( Document *  document)