/*
* sql_builder.c
*
- * Copyright (C) 2010-2016 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2010-2019 Andrea Zagli <azagli@libero.it>
*
* This file is part of libgdaex.
*
return priv->id_where;
}
+GdaSqlBuilderId
+gdaex_sql_builder_where_int (GdaExSqlBuilder *sqlb, GdaSqlOperatorType op,
+ const gchar *table_name,
+ const gchar *field_name,
+ const gchar *field_alias,
+ GdaSqlOperatorType where_op,
+ gint op1,
+ gint op2)
+{
+ GValue *val1;
+ GValue *val2;
+
+ GdaSqlBuilderId id;
+
+ val1 = g_new0 (GValue, 1);
+ g_value_init (val1, G_TYPE_INT);
+ g_value_set_int (val1, op1);
+
+ val2 = g_new0 (GValue, 1);
+ g_value_init (val2, G_TYPE_INT);
+ g_value_set_int (val2, op2);
+
+ id = gdaex_sql_builder_where (sqlb, op, table_name, field_name, field_alias, where_op, val1, val2, NULL);
+
+ g_value_unset (val1);
+ g_value_unset (val2);
+
+ return id;
+}
+
/**
* gdaex_sql_builder_order:
* @sqlb:
/*
* sqlbuilder.h
*
- * Copyright (C) 2015-2016 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2019 Andrea Zagli <azagli@libero.it>
*
* This file is part of libgdaex.
*
GdaSqlBuilderId gdaex_sql_builder_where (GdaExSqlBuilder *sqlb, GdaSqlOperatorType op,
...);
+GdaSqlBuilderId gdaex_sql_builder_where_int (GdaExSqlBuilder *sqlb, GdaSqlOperatorType op,
+ const gchar *table_name,
+ const gchar *field_name,
+ const gchar *field_alias,
+ GdaSqlOperatorType where_op,
+ gint op1,
+ gint op2);
void gdaex_sql_builder_order (GdaExSqlBuilder *sqlb, ...);
/*
- * Copyright (C) 2015 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2019 Andrea Zagli <azagli@libero.it>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
g_object_unref (sqlb);
+ sqlb = gdaex_sql_builder_new (GDA_SQL_STATEMENT_DELETE);
+
+ gdaex_sql_builder_from_v (sqlb,
+ "pippo", "pluto",
+ "topolino", "",
+ NULL);
+
+ gdaex_sql_builder_where_int (sqlb, 0,
+ "pippo", "id", "",
+ GDA_SQL_OPERATOR_TYPE_EQ,
+ 1, 0);
+
+ gdaex_sql_builder_where_int (sqlb, GDA_SQL_OPERATOR_TYPE_OR,
+ "pippo", "id", "",
+ GDA_SQL_OPERATOR_TYPE_BETWEEN,
+ 1, 99);
+
+ g_message ("sql: %s", gdaex_sql_builder_get_sql (sqlb, NULL, NULL));
+
+ g_object_unref (sqlb);
+
sqlb = gdaex_sql_builder_new (GDA_SQL_STATEMENT_UPDATE);
gdaex_sql_builder_from_v (sqlb,
gdaex_sql_builder_fields (sqlb,
"pippo", "name", "", gval,
NULL);
+ g_value_unset (gval);
gval = g_new0 (GValue, 1);
g_value_init (gval, G_TYPE_INT);