aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mysqlerl.erl6
-rw-r--r--src/mysqlerl.hrl1
-rw-r--r--src/mysqlerl_connection.erl8
3 files changed, 8 insertions, 7 deletions
diff --git a/src/mysqlerl.erl b/src/mysqlerl.erl
index ddc8857..aae7fda 100644
--- a/src/mysqlerl.erl
+++ b/src/mysqlerl.erl
@@ -4,6 +4,8 @@
-module(mysqlerl).
-author('bjc@kublai.com').
+-include("mysqlerl.hrl").
+
-export([test_start/0, test_msg/0]).
-export([start/0, start/1, stop/0, commit/2, commit/3,
@@ -193,5 +195,5 @@ sql_query(Ref, SQLQuery) ->
%% Returns:
%% {selected, ColNames, Rows} | {error, Reason}
%% Rows = rows()
-sql_query(_Ref, _SQLQuery, _Timeout) ->
- ?NOTIMPLEMENTED.
+sql_query(Ref, SQLQuery, Timeout) ->
+ gen_server:call(Ref, #sql_query{q = SQLQuery}, Timeout).
diff --git a/src/mysqlerl.hrl b/src/mysqlerl.hrl
new file mode 100644
index 0000000..aabd384
--- /dev/null
+++ b/src/mysqlerl.hrl
@@ -0,0 +1 @@
+-record(sql_query, {q}).
diff --git a/src/mysqlerl_connection.erl b/src/mysqlerl_connection.erl
index 35c69b2..cdb19c8 100644
--- a/src/mysqlerl_connection.erl
+++ b/src/mysqlerl_connection.erl
@@ -1,16 +1,17 @@
-module(mysqlerl_connection).
-author('bjc@kublai.com').
+-include("mysqlerl.hrl").
+
-behavior(gen_server).
--export([start_link/6, stop/1, sql_query/3]).
+-export([start_link/6, stop/1]).
-export([init/1, terminate/2, code_change/3,
handle_call/3, handle_cast/2, handle_info/2]).
-record(state, {ref}).
-record(port_closed, {reason}).
--record(sql_query, {q}).
start_link(Host, Port, Database, User, Password, Options) ->
gen_server:start_link(?MODULE, [Host, Port, Database,
@@ -19,9 +20,6 @@ start_link(Host, Port, Database, User, Password, Options) ->
stop(Pid) ->
gen_server:cast(Pid, stop).
-sql_query(Pid, Query, Timeout) ->
- gen_server:call(Pid, #sql_query{q = Query}, Timeout).
-
init([Host, Port, Database, User, Password, Options]) ->
process_flag(trap_exit, true),
Cmd = lists:flatten(io_lib:format("~s ~s ~w ~s ~s ~s ~s",