mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Merge pull request #273 from gamenet/master
odb_queries patch return value of functions update and update_t in case of sql insert
This commit is contained in:
commit
0917209711
@ -296,8 +296,9 @@ get_sm_features(Acc, _From, _To, _Node, _Lang) ->
|
|||||||
|
|
||||||
store_packet(From, To, Packet) ->
|
store_packet(From, To, Packet) ->
|
||||||
Type = xml:get_tag_attr_s(<<"type">>, Packet),
|
Type = xml:get_tag_attr_s(<<"type">>, Packet),
|
||||||
|
BodyElem = xml:get_path_s(Packet,[{elem, <<"body">>}]),
|
||||||
if (Type /= <<"error">>) and (Type /= <<"groupchat">>)
|
if (Type /= <<"error">>) and (Type /= <<"groupchat">>)
|
||||||
and (Type /= <<"headline">>) ->
|
and (Type /= <<"headline">>) and (<<>> /= BodyElem) ->
|
||||||
case has_no_storage_hint(Packet) of
|
case has_no_storage_hint(Packet) of
|
||||||
false ->
|
false ->
|
||||||
case check_event(From, To, Packet) of
|
case check_event(From, To, Packet) of
|
||||||
|
@ -97,10 +97,14 @@ update_t(Table, Fields, Vals, Where) ->
|
|||||||
of
|
of
|
||||||
{updated, 1} -> ok;
|
{updated, 1} -> ok;
|
||||||
_ ->
|
_ ->
|
||||||
ejabberd_odbc:sql_query_t([<<"insert into ">>, Table,
|
Res = ejabberd_odbc:sql_query_t([<<"insert into ">>, Table,
|
||||||
<<"(">>, join(Fields, <<", ">>),
|
<<"(">>, join(Fields, <<", ">>),
|
||||||
<<") values ('">>, join(Vals, <<"', '">>),
|
<<") values ('">>, join(Vals, <<"', '">>),
|
||||||
<<"');">>])
|
<<"');">>]),
|
||||||
|
case Res of
|
||||||
|
{updated,1} -> ok;
|
||||||
|
_ -> Res
|
||||||
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
update(LServer, Table, Fields, Vals, Where) ->
|
update(LServer, Table, Fields, Vals, Where) ->
|
||||||
@ -115,10 +119,14 @@ update(LServer, Table, Fields, Vals, Where) ->
|
|||||||
of
|
of
|
||||||
{updated, 1} -> ok;
|
{updated, 1} -> ok;
|
||||||
_ ->
|
_ ->
|
||||||
ejabberd_odbc:sql_query(LServer,
|
Res = ejabberd_odbc:sql_query(LServer,
|
||||||
[<<"insert into ">>, Table, <<"(">>,
|
[<<"insert into ">>, Table, <<"(">>,
|
||||||
join(Fields, <<", ">>), <<") values ('">>,
|
join(Fields, <<", ">>), <<") values ('">>,
|
||||||
join(Vals, <<"', '">>), <<"');">>])
|
join(Vals, <<"', '">>), <<"');">>]),
|
||||||
|
case Res of
|
||||||
|
{updated,1} -> ok;
|
||||||
|
_ -> Res
|
||||||
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% F can be either a fun or a list of queries
|
%% F can be either a fun or a list of queries
|
||||||
|
Loading…
Reference in New Issue
Block a user