This commit is contained in:
aozhiwei 2020-06-24 13:38:12 +08:00
parent d73ff7eb0c
commit 645913c9d4

View File

@ -143,7 +143,8 @@ namespace a8
int Query::ExecQuery(const char* querystr, std::vector<a8::XValue> args) int Query::ExecQuery(const char* querystr, std::vector<a8::XValue> args)
{ {
impl_->FreeLastDataSet(); impl_->FreeLastDataSet();
int err = mysql_query(impl_->Conn(), FormatSql(querystr, args).c_str()); std::string real_sql = FormatSql(querystr, args).c_str();
int err = mysql_query(impl_->Conn(), real_sql.c_str());
if(err == 0){ if(err == 0){
impl_->mysqlres = mysql_store_result(impl_->Conn()); impl_->mysqlres = mysql_store_result(impl_->Conn());
if(RowsNum() > 0){ if(RowsNum() > 0){
@ -157,7 +158,8 @@ namespace a8
bool Query::ExecScript(const char* scriptstr, std::vector<a8::XValue> args) bool Query::ExecScript(const char* scriptstr, std::vector<a8::XValue> args)
{ {
impl_->FreeLastDataSet(); impl_->FreeLastDataSet();
return mysql_query(impl_->Conn(), FormatSql(scriptstr , args).c_str()) == 0; std::string real_sql = FormatSql(scriptstr , args).c_str();
return mysql_query(impl_->Conn(), real_sql.c_str()) == 0;
} }
std::string Query::FormatSqlEx(const char* fmt, std::vector<a8::XValue> args) std::string Query::FormatSqlEx(const char* fmt, std::vector<a8::XValue> args)