- 时间:2020-02-09 23:46 编辑: 来源: 阅读:
- 扫一扫,手机访问
摘要:Thinkphp 中 distinct 的用法解析
TP中distinct()的用处主要是去除重复的值
在Thinkphp手册中也详细说明了(链接:[url=http://document.thinkphp.cn/manual_3_2.html#distinct]http://document.thinkphp.cn/manual_3_2.html#distinct[/url])
下面是我的个人例子:
[img]http://files.jb51.net/file_images/article/201612/2016121414434419.png[/img]
显示的是这样的
[img]http://files.jb51.net/file_images/article/201612/2016121414434420.png[/img]
在加入distinct的话:
[img]http://files.jb51.net/file_images/article/201612/2016121414434421.png[/img]
显示结果为
[img]http://files.jb51.net/file_images/article/201612/2016121414434422.png[/img]
下面为贴出来的代码
$offernum = M('offer')->distinct(true)->where('order_id='.$order_id)->field('user_id,number')->select();
dump($offernum);
以上所述是小编给大家介绍的Thinkphp 中 distinct 的用法解析,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对编程素材网网站的支持!