00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _QUERY_H
00021 #define _QUERY_H
00022
00023
00024 #define DQ_XML_ENDTAG 1
00025 #define DQ_XML_CDATASTRINGS 2
00026 #define DQ_XML_TYPEINFO 4
00027 #define DQ_XML_APPEND 8
00028 #define DQ_XML_BEGIN 16
00029 #define DQ_XML_END 32
00030
00031 class Database;
00032 class Session;
00033
00034
00035 typedef struct tmpstrstruct
00036 {
00037 struct tmpstrstruct *next;
00038 char *buffer;
00039 short temporary;
00040 } TMPSTR;
00041
00042 class Query
00043 {
00044 public:
00045 Query();
00046 Query(Database *dbin);
00047 Query(Database *dbin,const char *sql);
00048 virtual ~Query();
00049
00050 short execute(const char *sql);
00051 short execute(const std::string &);
00052
00053
00054
00055 bool get_result(const char *sql,char **attrs = NULL);
00056 bool get_result(const std::string &);
00057 void free_result();
00058 bool fetch_row();
00059 long insert_id();
00060 long num_rows();
00061
00062
00063
00064 char * get_string(const char *sql);
00065 double get_num(const char *sql);
00066 long get_count(const char *sql);
00067
00068 char * get_string(const std::string &);
00069 double get_num(const std::string &);
00070 long get_count(const std::string &);
00071
00072 char * getstr(int x);
00073 double getnum(int x);
00074 long getval(int x);
00075
00076 char * getstr();
00077 double getnum();
00078 long getval();
00079
00080 void debug(short val);
00081 void syslog(short val);
00082
00083
00084
00085
00086 char * fetch_fieldname();
00087
00088
00089
00090
00091
00092 bool GotMore();
00093
00094 char * allocsafestr(const char *s);
00095 void safestr(const char *src,char *dest);
00096 char * gettmpstr(int);
00097 void safestr(std::string &);
00098
00099 std::string XMLSafe(const std::string &);
00100 void ReturnRowAsXML(std::string &,const std::string & = "",long = DQ_XML_ENDTAG) {}
00101
00102 int num_cols() { return m_ncolumns; }
00103 bool getcol(std::string &colname,std::string &coltype,int &width,int &dec,int &nullable);
00104 bool getcol(int x,std::string &colname,std::string &coltype,int &width,int &dec,int &nullable);
00105
00106 private:
00107 void unsafestr(char *s);
00108
00109 Database *db;
00110 Session *odb;
00111
00112
00113 char ** res;
00114 char * row[256];
00115
00116 TMPSTR *m_tmpstrbase;
00117 short rowcount;
00118 short _debug;
00119 short _syslog;
00120 int m_fetchrows;
00121 int m_results;
00122 int m_ncolumns;
00123 };
00124
00125
00126
00127 #endif // _QUERY_H