Browse Source

增加GROUP BY\HAVING支持

xx 1 year ago
parent
commit
907ee1263c
2 changed files with 18 additions and 0 deletions
  1. 16 0
      src/mysql.cpp
  2. 2 0
      src/mysql.h

+ 16 - 0
src/mysql.cpp

@@ -98,6 +98,20 @@ module::select& module::select::orderby(const std::string& exp)
     return *this;
 }
 
+module::select& module::select::groupby(const std::string& exp)
+{
+    // TODO: 在此处插入 return 语句
+    m_select->groupby(exp);
+    return *this;
+}
+
+module::select& module::select::having(const std::string& exp)
+{
+    // TODO: 在此处插入 return 语句
+    m_select->having(exp);
+    return *this;
+}
+
 void module::select::clear()
 {
     m_select->clear();
@@ -120,6 +134,8 @@ void module::select::regist(sol::state* lua)
         "field", &module::select::field,
         "limit", &module::select::limit,
         "orderby", &module::select::orderby,
+        "groupby", &module::select::groupby,
+        "having", &module::select::having,
         "page", &module::select::page,
         "table", &module::select::table,
         "where_dob", &module::select::where_dob,

+ 2 - 0
src/mysql.h

@@ -94,6 +94,8 @@ namespace module
 		module::select& page(uint32 page, uint32 count);
 		module::select& limit(uint32 start, uint32 count);
 		module::select& orderby(const std::string& exp);
+		module::select& groupby(const std::string& exp);
+		module::select& having(const std::string& exp);
 		void clear();
 		std::shared_ptr<module::mysql_result> query();
 		uint64 count();