![]() |
![]() |
![]() |
GNOME Data Access 3.0 manual | ![]() |
---|
Each time we execute a normal query, we will obtain a GdaDataModel object, which is the way to see what the query returned. As GdaDataModel is an object, we can manage it with GdaDataModel class.
Before continuing, we must say that it is possible to modify a data model, but as we are accessing using SQL, it is not recommended to modify it, so modifications on the database must be done using SQL.
Let's see the functions we need:
gda_data_model_get_column_position()
gda_data_model_get_row()
gda_row_get_value()
This functions are very easy to use, so let's see some clear examples:
This function accesses the data model by directly accessing cells (using gda_data_model_get_value_at () )
void show_table (GdaDataModel * dm) { gint row_id; gint column_id; GdaValue *value; for (column_id = 0; column_id < gda_data_model_get_n_columns (dm); column_id++) g_print("%s\t",gda_data_model_get_column_title (dm, column_id)); g_print("\n"); for (row_id = 0; row_id < gda_data_model_get_n_rows (dm); row_id++) { for (column_id = 0; column_id < gda_data_model_get_n_columns (dm); column_id++) { char *str; value = gda_data_model_get_value_at (dm, column_id, row_id); str = gda_value_stringify (value); g_print ("%s\t", str); } g_print("\n"); } }
Loop for writing column names. |
|
Double loop accessing values using gda_data_model_get_value_at () |
|
Data returned is a GdaValue object. |
This function accesses the data model by accessing rows (using gda_data_model_get_row () and gda_row_get_value () )