Got problem when using Model

35 views
Skip to first unread message

Sid Wu

unread,
Oct 10, 2014, 3:34:48 AM10/10/14
to chica...@googlegroups.com

Hi guys ,

These are my code and table:
deal(MacID, FromUserName, Site) ->
WeixinLog = boss_db:find(weixin, [{macid, 'equals', MacID}]),
{output, WeixinLog:id()};

Model:
-module(weixin, [Id, Macid, Site, Created, Fromusername, Ticket]).
-compile(export_all).
-table("weixinTest").

Table:
CREATE TABLE weixinTest (
id int(11) NOT NULL AUTO_INCREMENT,
macid varchar(20) NOT NULL,
site varchar(100) NOT NULL,
created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
fromusername varchar(255) NOT NULL,
ticket varchar(255) NOT NULL,
PRIMARY KEY (id)
)

I got this when visit the url:
10:28:31.682 [info] Query SELECT * FROM weixinTest WHERE macid = 'fawfwaf' AND TRUE ORDER BY id ASC
10:28:31.687 [error] Error in controller error badarg [{erlang,apply,[[{weixin,"weixin-1",<<"fawfwaf">>,<<"weixin">>,{{2014,10,9},{14,16,44}},<<"wbfwbf">>,<<"fwafwaf">>}],id,[]],[]},{weixin_t1_s_controller,deal,4,[{file,"/home/sid/weixin_t1/src/controller/weixin_t1_s_controller.erl"},{line,12}]},{boss_web_controller,call_controller_action,3,[{file,"src/boss/boss_web_controller.erl"},{line,316}]},{boss_web_controller,apply_action,4,[{file,"src/boss/boss_web_controller.erl"},{line,308}]},{boss_web_controller,execute_action_inner,9,[{file,"src/boss/boss_web_controller.erl"},{line,287}]},{boss_web_controller_handle_request,process_dynamic_request,5,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,254}]},{boss_web_controller_handle_request,process_request,5,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,240}]},{boss_web_controller_handle_request,set_timer,8,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,160}]}]

What's the problem?

chan sisowath

unread,
Oct 10, 2014, 5:19:21 AM10/10/14
to chica...@googlegroups.com
hi,

i guess,

boss_db:find(...) return a list of record, then WeixinLog:id() doesn't apply here,

try boss_db:find_first(...) or use this:

[WeixinLog|_] = boss_db:find(weixin, [{macid, 'equals', MacID}]),

mihawk






--
You received this message because you are subscribed to the Google Groups "ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss...@googlegroups.com.
Visit this group at http://groups.google.com/group/chicagoboss.
To view this discussion on the web visit https://groups.google.com/d/msgid/chicagoboss/0170a5ed-0ee4-4da0-a4e7-d18b44dfcd53%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

can2nac

unread,
Oct 10, 2014, 10:16:23 AM10/10/14
to chica...@googlegroups.com
not sure about

[WeixinLog|_] = boss_db:find(weixin, [{macid, 'equals', MacID}]),

in case find returns []

can2nac

unread,
Oct 10, 2014, 10:17:54 AM10/10/14
to chica...@googlegroups.com
or if it returns {error, Reason}
Reply all
Reply to author
Forward
0 new messages