00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef RESOURCEPOOL_MYSQL_RESOURCEPOOL_HH
00025 #include <ResourcePool.hh>
00026 #endif
00027
00028 #ifndef RESOURCEPOOL_MYSQL_SQLSELECT_HH
00029 #define RESOURCEPOOL_MYSQL_SQLSELECT_HH
00030
00031 #ifndef RESOURCEPOOL_COMMAND_HH
00032 #include "ResourcePool/Command.hh"
00033 #endif
00034
00035 #ifndef RESOURCEPOOL_MYSQL_MYSQLFWD_HH
00036 #include "mysqlFwd.hh"
00037 #endif
00038
00039 #ifndef RESOURCEPOOL_MYSQL_SQLTYPE_HH
00040 #include "SQLType.hh"
00041 #endif
00042
00043 #ifndef INCLUDED_GC_PTR_HH
00044 #include "mm/gc_ptr.hh"
00045 #endif
00046
00047 #ifndef RESOURCEPOOL_SQL_BIND_HH
00048 #include "ResourcePool/SQL/Bind.hh"
00049 #endif
00050
00051 #ifndef RESOURCEPOOL_SQL_BINDOUT_HH
00052 #include "ResourcePool/SQL/BindOut.hh"
00053 #endif
00054
00055 #ifndef RESOURCEPOOL_SQL_SQLSELECT_HH
00056 #include "ResourcePool/SQL/SQLSelect.hh"
00057 #endif
00058
00059 #include <string>
00060 #include <vector>
00061
00062 namespace fatalmind {
00063 namespace mysql {
00064
00065 namespace internal {
00066 class registerFinish;
00067 }
00068
00073 class SQLSelect
00074 : public Command<fatalmind::ResourceType::mysql>
00075 , public SQL::Bind<SQLType, SQLTypeImpl>
00076 , public SQL::BindOut<SQLRefType, SQLRefTypeImpl>
00077 , public fatalmind::SQLSelect
00078 {
00079 protected:
00080 typedef SQL::Bind<SQLType, SQLTypeImpl> super_bind;
00081 typedef fatalmind::SQLSelect super;
00082 public:
00083 SQLSelect(const std::string& SQL, SQL::SQLFetcher& fetcher);
00084 SQLSelect(const ResourcePool<ResourceType>& p, const std::string& SQL, SQL::SQLFetcher& fetcher);
00085 virtual ~SQLSelect();
00086 virtual void execute(mysqlResource&);
00087
00088 virtual void outputoperator(std::ostream&) const;
00089
00090 protected:
00091 virtual Clone* DoClone() const {
00092 return new SQLSelect(*this);
00093 }
00094 bool ishighlimit(int) const;
00095 bool islowlimit(int) const;
00096
00097 std::string _SQL;
00098
00099 int highlimit;
00100
00101 int lowlimit;
00102
00103
00104
00105 bool hardhighlimit;
00106 private:
00107 virtual bool fetch();
00108 void finish();
00109 void close_rs();
00110
00111 MYSQL_RES* _rs;
00112 unsigned int _num_fields;
00113 friend
00114 class internal::registerFinish;
00115 };
00116
00117 namespace internal {
00118 class registerFinish {
00119 public:
00120 registerFinish(SQLSelect& select)
00121 : _select(select)
00122 {
00123 }
00124 ~registerFinish()
00125 {
00126 _select.finish();
00127 }
00128 private:
00129 SQLSelect& _select;
00130 };
00131 }
00132
00133
00134 }
00135 }
00136 #endif