diff --git a/include/db/sqler.h b/include/db/sqler.h
index 77cfbd1..b5eb06b 100644
--- a/include/db/sqler.h
+++ b/include/db/sqler.h
@@ -81,6 +81,8 @@ namespace ylib
/// 查询
///
ylib::mysql::result* query();
+
+ void clear();
#if 0
///
/// 查询转换为layui需求模板
@@ -159,6 +161,8 @@ namespace ylib
/// 查询
///
uint64 exec();
+
+ void clear();
private:
///
/// 生成SQL片段
@@ -199,6 +203,8 @@ namespace ylib
/// 查询
///
uint64 exec();
+
+ void clear();
private:
mysql::conn* m_conn = nullptr;
std::string m_table_name;
@@ -245,6 +251,8 @@ namespace ylib
/// 查询
///
uint64 exec();
+
+ void clear();
private:
///
/// 生成SQL片段
diff --git a/src/db/sqler.cpp b/src/db/sqler.cpp
index 056c39f..40c3a17 100644
--- a/src/db/sqler.cpp
+++ b/src/db/sqler.cpp
@@ -207,6 +207,15 @@ ylib::mysql::result* ylib::select::query()
setInsetValue(ppst, i + 1, insert_values[i]);
return ppst->query();
}
+void ylib::select::clear()
+{
+ m_wheres.clear();
+ m_table_name = "";
+ m_fields.clear();
+ m_limit.count = -1;
+ m_limit.start = -1;
+ m_orderby.field = "";
+}
void ylib::select::make_sql(std::string& field_name, std::string& where, std::string& orderby, std::string& limit, std::vector& insert_values)
{
if (m_fields.size() == 0)
@@ -367,6 +376,16 @@ uint64 ylib::update::exec()
return ppst->update();
}
+void ylib::update::clear()
+{
+ m_wheres.clear();
+ m_table_name = "";
+ m_limit.count = -1;
+ m_limit.start = -1;
+ m_orderby.field = "";
+ m_sets.clear();
+}
+
void ylib::update::make_sql(std::string& set, std::string& where, std::string& orderby, std::string& limit, std::vector& insert_values)
{
{
@@ -494,6 +513,13 @@ uint64 ylib::insert::exec()
return ppst->update();
}
+void ylib::insert::clear()
+{
+ m_table_name = "";
+ m_sets.clear();
+
+}
+
@@ -594,6 +620,15 @@ uint64 ylib::delete_::exec()
return ppst->update();
}
+void ylib::delete_::clear()
+{
+ m_wheres.clear();
+ m_table_name = "";
+ m_limit.count = -1;
+ m_limit.start = -1;
+ m_orderby.field = "";
+}
+
void ylib::delete_::make_sql(std::string& where, std::string& orderby, std::string& limit, std::vector& insert_values)
{
if (m_wheres.size() != 0)