Dynamic SQL Query based on referenced URL variables...

agolangf · · 405 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>What I&#39;m trying to accomplish:</p> <p><a href="http://www.mysite.com/api?firstname=John&amp;lastname=Smith" rel="nofollow">http://www.mysite.com/api?firstname=John&amp;lastname=Smith</a></p> <p>In the code, I need to dynamically generate a sql query based on the referenced URL variables (some or none could be specified... so it needs to be adaptive). To prevent SQL-injection, I need to structure the query in a way where the values of variables are appended to the &#39;...interface{}&#39; parameter of the db.Query() function (in the standard library).</p> <p>This seems like an easy thing to do, but it isn&#39;t. If I could somehow convert a []interface{} that would satisfy the &#39;...interface{}&#39; (with the slice containing a pointer to the string holding the value) of the db.Query() call... that would work; however, I don&#39;t think that&#39;s possible. Any 3rd-party import or other advice on how to get what I&#39;m needing going?</p>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

405 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传