summaryrefslogtreecommitdiff
path: root/src/char/inter.c
diff options
context:
space:
mode:
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;
}