修复部分问题

This commit is contained in:
xx
2025-02-20 00:35:57 +08:00
parent cd8beae98a
commit 445e49eff5
6 changed files with 33 additions and 32 deletions

View File

@@ -92,9 +92,9 @@ module::select& module::select::limit(uint32 start, uint32 count)
return *this; return *this;
} }
module::select& module::select::orderby(const std::string& field, int sort) module::select& module::select::orderby(const std::string& exp)
{ {
m_select->orderby(field,(ylib::sort)sort); m_select->orderby(exp);
return *this; return *this;
} }
@@ -235,9 +235,9 @@ module::update& module::update::limit(uint32 start, uint32 count)
return *this; return *this;
} }
module::update& module::update::orderby(const std::string& field, int sort) module::update& module::update::orderby(const std::string& exp)
{ {
m_update->orderby(field,(ylib::sort)sort); m_update->orderby(exp);
return *this; return *this;
} }
@@ -418,9 +418,9 @@ module::delete_& module::delete_::limit(uint32 start, uint32 count)
return *this; return *this;
} }
module::delete_& module::delete_::orderby(const std::string& field, int sort) module::delete_& module::delete_::orderby(const std::string& exp)
{ {
m_delete->orderby(field, (ylib::sort)sort); m_delete->orderby(exp);
return *this; return *this;
} }
@@ -453,9 +453,6 @@ void module::delete_::regist(sol::state* lua)
void module::mysql_regist(sol::state* lua) void module::mysql_regist(sol::state* lua)
{ {
(*lua)["DESC"] = ylib::sort::DESC;
(*lua)["ASC"] = ylib::sort::ASC;
//lua->new_usertype<ylib::mysql::conn>("mysql_conn", //lua->new_usertype<ylib::mysql::conn>("mysql_conn",
// "clear", &ylib::mysql::conn::clear, // "clear", &ylib::mysql::conn::clear,
// "close", &ylib::mysql::conn::close, // "close", &ylib::mysql::conn::close,
@@ -569,10 +566,10 @@ uint32 module::mysql_result::field_count()
std::string module::mysql_result::field_type(sol::object obj) std::string module::mysql_result::field_type(sol::object obj)
{ {
if (obj.is<int>() || obj.is<double>()) { if (obj.is<int>() || obj.is<double>()) {
m_result->field_type((uint32)obj.as<int>()); return m_result->field_type((uint32)obj.as<int>());
} }
else if (obj.is<std::string>()) { else if (obj.is<std::string>()) {
m_result->field_type((std::string)obj.as<std::string>()); return m_result->field_type((std::string)obj.as<std::string>());
} }
return ""; return "";
} }
@@ -610,7 +607,7 @@ sol::object module::mysql_result::get(sol::object obj, sol::this_state s)
GET_VALUE(get_int32); GET_VALUE(get_int32);
} }
else if (type == "varchar" || type == "char" || type == "text" || type == "datetime") else if (type == "varchar" || type == "char" || type == "text" || type == "datetime" || type == "date")
{ {
GET_VALUE(get_string); GET_VALUE(get_string);
} }
@@ -643,6 +640,10 @@ sol::object module::mysql_result::get(sol::object obj, sol::this_state s)
rd[i] = rb[i]; rd[i] = rb[i];
return sol::make_object(s,rd); return sol::make_object(s,rd);
} }
else
{
GET_VALUE(get_string);
}
return sol::make_object(s, sol::nil); return sol::make_object(s, sol::nil);
} }

View File

@@ -93,7 +93,7 @@ namespace module
module::select& field(sol::table table); module::select& field(sol::table table);
module::select& page(uint32 page, uint32 count); module::select& page(uint32 page, uint32 count);
module::select& limit(uint32 start, uint32 count); module::select& limit(uint32 start, uint32 count);
module::select& orderby(const std::string& field, int sort); module::select& orderby(const std::string& exp);
void clear(); void clear();
std::shared_ptr<module::mysql_result> query(); std::shared_ptr<module::mysql_result> query();
uint64 count(); uint64 count();
@@ -120,7 +120,7 @@ namespace module
module::update& where_expression(const std::string& expression); module::update& where_expression(const std::string& expression);
module::update& page(uint32 page, uint32 count); module::update& page(uint32 page, uint32 count);
module::update& limit(uint32 start, uint32 count); module::update& limit(uint32 start, uint32 count);
module::update& orderby(const std::string& field, int sort); module::update& orderby(const std::string& exp);
uint64 exec(); uint64 exec();
void clear(); void clear();
static void regist(sol::state* lua); static void regist(sol::state* lua);
@@ -158,7 +158,7 @@ namespace module
module::delete_& where_expression(const std::string& expression); module::delete_& where_expression(const std::string& expression);
module::delete_& page(uint32 page, uint32 count); module::delete_& page(uint32 page, uint32 count);
module::delete_& limit(uint32 start, uint32 count); module::delete_& limit(uint32 start, uint32 count);
module::delete_& orderby(const std::string& field, int sort); module::delete_& orderby(const std::string& exp);
uint64 exec(); uint64 exec();
void clear(); void clear();
static void regist(sol::state* lua); static void regist(sol::state* lua);

View File

@@ -102,14 +102,14 @@ function mysql_builder_delete:limit(start, count)
return self return self
end end
--[[ --[[
设置排序 设置排序
@param field 字段名称 @param orderby 排序语句
@param sort 排序方式(升序或降序) @return 返回 mysql_builder_select 对象自身,以便链式调用
@return 返回 mysql_builder_delete 对象自身,以便链式调用
]] ]]
function mysql_builder_delete:orderby(field, sort) function mysql_builder_delete:orderby(orderby)
self.module:orderby(field, sort) self.module:orderby(orderby)
return self return self
end end

View File

@@ -126,12 +126,11 @@ end
--[[ --[[
设置排序 设置排序
@param field 字段名称 @param orderby 排序语句
@param sort 排序方式(升序或降序)
@return 返回 mysql_builder_select 对象自身,以便链式调用 @return 返回 mysql_builder_select 对象自身,以便链式调用
]] ]]
function mysql_builder_select:orderby(field, sort) function mysql_builder_select:orderby(orderby)
self.module:orderby(field, sort) self.module:orderby(orderby)
return self return self
end end

View File

@@ -169,15 +169,13 @@ end
--[[ --[[
设置排序 设置排序
@param field 字段名称 @param orderby 排序语句
@param sort 排序方式(升序或降序) @return 返回 mysql_builder_select 对象自身,以便链式调用
@return 返回 mysql_builder_update 对象自身,以便链式调用
]] ]]
function mysql_builder_update:orderby(field, sort) function mysql_builder_update:orderby(orderby)
self.module:orderby(field, sort) self.module:orderby(orderby)
return self return self
end end
--[[ --[[
执行更新操作 执行更新操作
@return 返回受影响的行数 @return 返回受影响的行数

View File

@@ -19,7 +19,7 @@ function mysql_conn.new(__module)
else else
instance.module = __module instance.module = __module
end end
print("M:",instance.module)
return instance return instance
end end
--[[ --[[
@@ -65,7 +65,10 @@ end
@param autocommit 是否自动提交 @param autocommit 是否自动提交
]] ]]
function mysql_conn:begin(autocommit) function mysql_conn:begin(autocommit)
self.module:begin(autocommit or false) if autocommit == nil then
autocommit = false
end
self.module:begin(autocommit)
end end
--[[ --[[