summaryrefslogtreecommitdiff
path: root/src/char/inter.c
diff options
context:
space:
mode:
authorepoque11 <epoque11@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-03-19 14:43:01 +0000
committerepoque11 <epoque11@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-03-19 14:43:01 +0000
commitd439d6d992f76dd547ccd8557e3aa58b11a3ef08 (patch)
tree95f00944cbd844056a339ff9aae6801d5dd7bc23 /src/char/inter.c
parent35074ab34ecd9264769784cf5263613c9497e26f (diff)
downloadhercules-d439d6d992f76dd547ccd8557e3aa58b11a3ef08.tar.gz
hercules-d439d6d992f76dd547ccd8557e3aa58b11a3ef08.tar.bz2
hercules-d439d6d992f76dd547ccd8557e3aa58b11a3ef08.tar.xz
hercules-d439d6d992f76dd547ccd8557e3aa58b11a3ef08.zip
- Updated existing registry saving code to perform one single uniform query. (bugreport:2848)
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15729 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/char/inter.c')
-rw-r--r--src/char/inter.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/src/char/inter.c b/src/char/inter.c
index c72c64108..752fe5163 100644
--- a/src/char/inter.c
+++ b/src/char/inter.c
@@ -68,7 +68,7 @@ static int wis_dellist[WISDELLIST_MAX], wis_delnum;
int inter_accreg_tosql(int account_id, int char_id, struct accreg* reg, int type)
{
struct global_reg* r;
- SqlStmt* stmt;
+ StringBuf buf;
int i;
if( account_id <= 0 )
@@ -100,24 +100,31 @@ int inter_accreg_tosql(int account_id, int char_id, struct accreg* reg, int type
if( reg->reg_num <= 0 )
return 0;
- stmt = SqlStmt_Malloc(sql_handle);
- if( SQL_ERROR == SqlStmt_Prepare(stmt, "INSERT INTO `%s` (`type`, `account_id`, `char_id`, `str`, `value`) VALUES ('%d','%d','%d',?,?)", reg_db, type, account_id, char_id) )
- SqlStmt_ShowDebug(stmt);
- for( i = 0; i < reg->reg_num; ++i )
- {
+ StringBuf_Init(&buf);
+ StringBuf_Printf(&buf, "INSERT INTO `%s` (`type`,`account_id`,`char_id`,`str`,`value`) VALUES ", reg_db);
+
+ for( i = 0; i < reg->reg_num; ++i ) {
r = &reg->reg[i];
- if( r->str[0] != '\0' && r->value != '\0' )
- {
- // str
- SqlStmt_BindParam(stmt, 0, SQLDT_STRING, r->str, strnlen(r->str, sizeof(r->str)));
- // value
- SqlStmt_BindParam(stmt, 1, SQLDT_STRING, r->value, strnlen(r->value, sizeof(r->value)));
+ if( r->str[0] != '\0' && r->value[0] != '\0' ) {
+ char str[32];
+ char val[256];
+
+ if( i > 0 )
+ StringBuf_AppendStr(&buf, ",");
- if( SQL_ERROR == SqlStmt_Execute(stmt) )
- SqlStmt_ShowDebug(stmt);
+ Sql_EscapeString(sql_handle, str, r->str);
+ Sql_EscapeString(sql_handle, val, r->value);
+
+ StringBuf_Printf(&buf, "('%d','%d','%d','%s','%s')", type, account_id, char_id, str, val);
}
}
- SqlStmt_Free(stmt);
+
+ if( SQL_ERROR == Sql_QueryStr(sql_handle, StringBuf_Value(&buf)) ) {
+ Sql_ShowDebug(sql_handle);
+ }
+
+ StringBuf_Destroy(&buf);
+
return 1;
}