return ret;
}
+/**
+ * gdaex_sql_builder_get_sql_select:
+ * @sqlb:
+ * @cnc:
+ * @params:
+ *
+ */
+gchar
+*gdaex_sql_builder_get_sql_select (GdaExSqlBuilder *sqlb, GdaConnection *cnc, GdaSet *params)
+{
+ gchar *ret;
+ gchar *sql;
+
+ gchar *start;
+ gchar *end;
+
+ ret = NULL;
+
+ sql = gdaex_sql_builder_get_sql (sqlb, cnc, params);
+ if (sql == NULL)
+ {
+ return ret;
+ }
+
+ start = g_strstr_len (sql, -1, "SELECT");
+ if (start == NULL)
+ {
+ return ret;
+ }
+
+ end = g_strstr_len (sql, -1, "FROM");
+ if (end == NULL)
+ {
+ return ret;
+ }
+
+ ret = g_strndup (start + 7, strlen (sql) - 8 - strlen (end));
+
+ g_free (sql);
+
+ return ret;
+}
+
+/**
+ * gdaex_sql_builder_get_sql_from:
+ * @sqlb:
+ * @cnc:
+ * @params:
+ *
+ */
+gchar
+*gdaex_sql_builder_get_sql_from (GdaExSqlBuilder *sqlb, GdaConnection *cnc, GdaSet *params)
+{
+ gchar *ret;
+ gchar *sql;
+
+ gchar *start;
+ gchar *end;
+
+ ret = NULL;
+
+ sql = gdaex_sql_builder_get_sql (sqlb, cnc, params);
+ if (sql == NULL)
+ {
+ return ret;
+ }
+
+ start = g_strstr_len (sql, -1, "FROM");
+ if (start == NULL)
+ {
+ return ret;
+ }
+
+ end = g_strstr_len (sql, -1, "WHERE");
+ if (end == NULL)
+ {
+ end = g_strstr_len (sql, -1, "ORDER BY");
+ }
+
+ ret = g_strndup (start + 5, strlen (start) - (end != NULL ? 6 : 5) - (end != NULL ? strlen (end) : 0));
+
+ g_free (sql);
+
+ return ret;
+}
+
+/**
+ * gdaex_sql_builder_get_sql_where:
+ * @sqlb:
+ * @cnc:
+ * @params:
+ *
+ */
+gchar
+*gdaex_sql_builder_get_sql_where (GdaExSqlBuilder *sqlb, GdaConnection *cnc, GdaSet *params)
+{
+ gchar *ret;
+ gchar *sql;
+
+ gchar *start;
+ gchar *end;
+
+ ret = NULL;
+
+ sql = gdaex_sql_builder_get_sql (sqlb, cnc, params);
+ if (sql == NULL)
+ {
+ return ret;
+ }
+
+ start = g_strstr_len (sql, -1, "WHERE");
+ if (start == NULL)
+ {
+ return ret;
+ }
+
+ end = g_strstr_len (sql, -1, "ORDER BY");
+
+ ret = g_strndup (start + 6, strlen (start) - (end != NULL ? 7 : 6) - (end != NULL ? strlen (end) : 0));
+
+ g_free (sql);
+
+ return ret;
+}
+
+/**
+ * gdaex_sql_builder_get_sql_order:
+ * @sqlb:
+ * @cnc:
+ * @params:
+ *
+ */
+gchar
+*gdaex_sql_builder_get_sql_order (GdaExSqlBuilder *sqlb, GdaConnection *cnc, GdaSet *params)
+{
+ gchar *ret;
+ gchar *sql;
+
+ gchar *start;
+
+ ret = NULL;
+
+ sql = gdaex_sql_builder_get_sql (sqlb, cnc, params);
+ if (sql == NULL)
+ {
+ return ret;
+ }
+
+ start = g_strstr_len (sql, -1, "ORDER BY");
+ if (start == NULL)
+ {
+ return ret;
+ }
+
+ ret = g_strndup (start + 9, strlen (start) - 9);
+
+ g_free (sql);
+
+ return ret;
+}
+
/**
* gdaex_sql_builder_query:
* @sqlb:
/*
* sqlbuilder.h
*
- * Copyright (C) 2015 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2016 Andrea Zagli <azagli@libero.it>
*
* This file is part of libgdaex.
*
void gdaex_sql_builder_field (GdaExSqlBuilder *sqlb, const gchar *table_name, const gchar *field_name, const gchar *field_alias, GValue *gval);
void gdaex_sql_builder_fields (GdaExSqlBuilder *sqlb, ...);
-GdaSqlBuilderId gdaex_sql_builder_where (GdaExSqlBuilder *sqln, GdaSqlOperatorType op,
+GdaSqlBuilderId gdaex_sql_builder_where (GdaExSqlBuilder *sqlb, GdaSqlOperatorType op,
...);
void gdaex_sql_builder_order (GdaExSqlBuilder *sqlb, ...);
GdaSqlBuilder *gdaex_sql_builder_get_gda_sql_builder (GdaExSqlBuilder *sqlb);
gchar *gdaex_sql_builder_get_sql (GdaExSqlBuilder *sqlb, GdaConnection *cnc, GdaSet *params);
+gchar *gdaex_sql_builder_get_sql_select (GdaExSqlBuilder *sqlb, GdaConnection *cnc, GdaSet *params);
+gchar *gdaex_sql_builder_get_sql_from (GdaExSqlBuilder *sqlb, GdaConnection *cnc, GdaSet *params);
+gchar *gdaex_sql_builder_get_sql_where (GdaExSqlBuilder *sqlb, GdaConnection *cnc, GdaSet *params);
+gchar *gdaex_sql_builder_get_sql_order (GdaExSqlBuilder *sqlb, GdaConnection *cnc, GdaSet *params);
GdaDataModel *gdaex_sql_builder_query (GdaExSqlBuilder *sqlb, GdaEx *gdaex, GdaSet *params);
gint gdaex_sql_builder_execute (GdaExSqlBuilder *sqlb, GdaEx *gdaex, GdaSet *params);