-define(generic, true).
-endif.
+%% Almost a copy of string:join/2.
+%% We use this version because string:join/2 is relatively
+%% new function (introduced in R12B-0).
+join([], _Sep) ->
+ [];
+join([H|T], Sep) ->
+ [H, [[Sep, X] || X <- T]].
+
%% -----------------
%% Generic queries
-ifdef(generic).
Fields, Vals),
case ejabberd_odbc:sql_query_t(
["update ", Table, " set ",
- string:join(UPairs, ", "),
+ join(UPairs, ", "),
" where ", Where, ";"]) of
{updated, 1} ->
ok;
_ ->
- %% The 'catch' herein is used because mysql returns
- %% affected rows (not matched as in postgresql).
- %% FIXME: need to find more suitable solution.
- catch ejabberd_odbc:sql_query_t(
- ["insert into ", Table, "(", string:join(Fields, ", "),
- ") values ('", string:join(Vals, "', '"), "');"])
+ ejabberd_odbc:sql_query_t(
+ ["insert into ", Table, "(", join(Fields, ", "),
+ ") values ('", join(Vals, "', '"), "');"])
end.
%% F can be either a fun or a list of queries
ejabberd_odbc:sql_query_t(
["insert into rostergroups("
" username, jid, grp) "
- " values ('", string:join(ItemGroup, "', '"), "');"])
+ " values ('", join(ItemGroup, "', '"), "');"])
end,
ItemGroups).
" username, jid, nick, "
" subscription, ask, askmessage, "
" server, subscribe, type) "
- " values ('", string:join(ItemVals, "', '"), "');"],
+ " values ('", join(ItemVals, "', '"), "');"],
["delete from rostergroups "
" where username='", Username, "' "
" and jid='", SJID, "';"]] ++
[["insert into rostergroups("
" username, jid, grp) "
- " values ('", string:join(ItemGroup, "', '"), "');"] ||
+ " values ('", join(ItemGroup, "', '"), "');"] ||
ItemGroup <- ItemGroups].
roster_subscribe(_LServer, Username, SJID, ItemVals) ->
"match_presence_out "
") "
"values ('", ID, "', '",
- string:join(Items, "', '"), "');"])
+ join(Items, "', '"), "');"])
end, RItems).
del_privacy_lists(LServer, Server, Username) ->