Closed tornodo closed 6 years ago
是的,这里最初的实现是按照列表来的,后来担心性能问题改为了只能查询一个。如果需要的话,你自己可以改一下。
收到。
size_t business_len = strlen(business);
if (business_len > 0) {
int _busLen = 2 * business_len + 1;
char _business[_busLen];
mysql_real_escape_string(conn, _business, business, business_len);
int count = 0;
sds* businessArray = sdssplitlen(_business, _busLen, ",", 1, &count);
if (count > 0) {
sds sql_business = sdsempty();
sql_business = sdscatprintf(sql_business, " AND (`business` = '%s'", businessArray[0]);
for (int i = 1;i < count;i++) {
sql_business = sdscatprintf(sql_business, " OR `business` = '%s'", businessArray[i]);
}
sql = sdscatprintf(sql, " %s)", sql_business);
sdsfree(sql_business);
} else {
sql = sdscatprintf(sql, " AND `business` = '%s'", _business);
}
sdsfreesplitres(businessArray, count);
}
改了改,仅供参考😄
rh_reader.c里面方法get_user_balance_history中
@haipome