00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef Composite_Query_HPP
00012 #define Composite_Query_HPP
00013
00014 #include "read_write_base.hpp"
00015
00016 class Composite_Query_Obj: public read_write_base
00017 {
00018 public:
00019 identifier Id;
00020 llong Site_Id;
00021 string Name;
00022 string Select_Part;
00023 string From_Part;
00024 string Where_Part;
00025 string Group_Part;
00026 string Having_Part;
00027 string Order_Part;
00028 bool Is_Workflow;
00029
00030 Composite_Query_Obj():read_write_base()
00031 ,Id(0LL)
00032 ,Site_Id(0LL)
00033 ,Name("")
00034 ,Select_Part("")
00035 ,From_Part("")
00036 ,Where_Part("")
00037 ,Group_Part("")
00038 ,Having_Part("")
00039 ,Order_Part("")
00040 ,Is_Workflow(false)
00041 {
00042
00043 data_name("Composite_Query");
00044
00045 addDXMap( new llongXfer("Id", &Id ));
00046 addDXMap( new llongXfer("Site_Id", &Site_Id ));
00047 addDXMap( new stringXfer("Name", &Name ));
00048 addDXMap( new stringXfer("Select_Part", &Select_Part ));
00049 addDXMap( new stringXfer("From_Part", &From_Part ));
00050 addDXMap( new stringXfer("Where_Part", &Where_Part ));
00051 addDXMap( new stringXfer("Group_Part", &Group_Part ));
00052 addDXMap( new stringXfer("Having_Part", &Having_Part ));
00053 addDXMap( new stringXfer("Order_Part", &Order_Part ));
00054 addDXMap( new boolXfer("Is_Workflow", &Is_Workflow ));
00055 }
00056
00057 void addTo_Where_Part( string toAdd )
00058 {
00059 if( Where_Part.length() ) Where_Part += " and ";
00060 Where_Part += toAdd;
00061 }
00062
00063 string asSQL( bool includeWhere = true )
00064 {
00065 string sql = "select " + Select_Part;
00066 sql += " from " + From_Part;
00067 if( includeWhere && Where_Part.length() )
00068 sql += " where " + Where_Part;
00069 if( Group_Part.length() )
00070 sql += " group by " + Group_Part;
00071 if( Having_Part.length() )
00072 sql += " having " + Having_Part;
00073 if( Order_Part.length() )
00074 sql += " order by " + Order_Part;
00075 return sql;
00076 }
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092 };
00093 #endif
00094
00095
00096