在此输入代码...-- query
local query_str = "select status from buystatus where uid='"..message["uid"].."'";
ngx.log(ngx.NOTICE, "query string: ", query_str);
local res, err, errno, sqlstate = db:query(query_str);
if not res then
insert_str = "insert into buystatus values('"..message["uid"].."',"..message["status"]..")";
ngx.log(ngx.ERR, "insert string: ", insert_str);
db:query(insert_str);
local msg = {};
msg["code"]=200;
msg["msg"]="Insert a new record success.";
to_send=cjson.encode(msg);
ngx.say(to_send);
return
end
update_str = "update buystatus set status="..message["status"].." where uid='"..message["uid"].."'";
db:query(update_str)