From b5a392e222d206b4a5f640ab1c71a7089baddb41 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Thu, 3 Dec 2015 16:52:05 +0100 Subject: [PATCH] Implemented ZakFormGdaexProvider::insert. --- src/form.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/form.c b/src/form.c index 4746198..899bb81 100644 --- a/src/form.c +++ b/src/form.c @@ -280,7 +280,44 @@ zak_form_gdaex_provider_load (ZakFormIProvider *provider, GPtrArray *elements) static gboolean zak_form_gdaex_provider_insert (ZakFormIProvider *provider, GPtrArray *elements) { + gboolean ret; + + guint i; + + GdaExSqlBuilder *sqlb; + + GdaDataModel *dm; + + ZakFormGdaexProviderPrivate *priv = ZAK_FORM_GDAEX_PROVIDER_GET_PRIVATE (provider); + g_return_val_if_fail (IS_GDAEX (priv->gdaex), FALSE); + + ret = TRUE; + + sqlb = gdaex_sql_builder_new (GDA_SQL_STATEMENT_INSERT); + + gdaex_sql_builder_from (sqlb, priv->table, NULL); + + for (i = 0; i < elements->len; i++) + { + ZakFormElement *element = (ZakFormElement *)g_ptr_array_index (elements, i); + if (zak_form_element_get_to_save (element)) + { + gdaex_sql_builder_field (sqlb, + priv->table, + zak_form_element_get_name (element), + "", + zak_form_gdaex_provider_new_gvalue_from_str_type (zak_form_element_get_provider_type (element), zak_form_element_get_value (element))); + } + } + + + if (gdaex_sql_builder_execute (sqlb, priv->gdaex, NULL) <= 0) + { + ret = FALSE; + } + + return ret; } static gboolean -- 2.49.0