midgard/query.h

00001 /* 
00002  * Copyright (C) 2005 Piotr Pokora <piotr.pokora@infoglob.pl>
00003  *
00004  * This program is free software; you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License as published
00006  * by the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  * 
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017  */
00018 
00019 #ifndef MIDGARD_QUERY
00020 #define MIDGARD_QUERY
00021 
00022 /* Executes SQL query without data returned.
00023  * 
00024  * @param mgd Midgard structure
00025  * @param sql SQL query which should be executed
00026  * @param user_data user data to pass to this function
00027  *
00028  * @return number of affected rows by the executed command, or -1 on failure
00029  */ 
00030 
00031 gint midgard_query_execute(midgard *mgd, gchar *sql, gpointer user_data);
00032 
00033 /* Executes SQL query and return data 
00034  *
00035  * @param sql SQL query which should be executed
00036  * @param object MgdObject 
00037  *
00038  * This function type cast selected values to object property type if found.
00039  * If object property is not found , value will be type casted to gpointer.
00040  * 
00041  * @return GList with rows value set as GList data or NULL on failure
00042  */ 
00043 
00044 GList *midgard_query_get_single_row(gchar *sql, MgdObject *object);
00045 
00046 
00047 /* Creates a table defined for object in schema. It also creates all fields
00048  * which should be used by object.
00049  *
00050  * @param object MgdObject object
00051  *
00052  * @return TRUE if successful, FALSE otherwise.
00053  */
00054 
00055 gboolean midgard_object_create_storage(MgdObject *object);
00056 
00057 /* 
00058  * Updates table defined for object.
00059  *
00060  * \param object MgdObject object
00061  *
00062  * \return TRUE if successfull , FALSE otherwise
00063  *
00064  */
00065 gboolean midgard_object_update_storage(MgdObject *object);
00066 
00067 /* Executes sql query and set object's properties.
00068  * 
00069  * @param sql SQL query which will be freed 
00070  * @param object MgdObject 
00071  *
00072  * @return TRUE if object's properties was set, FALSE otherwise.
00073  */ 
00074 gboolean midgard_object_set_from_query(gchar *sql, MgdObject *object);
00075 
00076 #endif

Generated on Thu Feb 22 06:15:14 2007 for midgard-core by  doxygen 1.4.6