thinkphp中distinct的用法是什么

thinkphp中distinct的用法是什么,第1张

thinkphp中distinct的用法是什么

thinkphp中,distinct()方法用于去除重复的值,能够返回唯一不同的值,distinct方法的参数是一个布尔值,语法为“$Model->distinct(布尔值参数)->field('name')->select();”。

本文 *** 作环境:Windows10系统、ThinkPHP5版、Dell G3电脑。

thinkphp中distinct的用法是什么

TP中distinct()的用处主要是去除重复的值

DISTINCT 方法用于返回唯一不同的值 。

$Model->distinct(true)->field('name')->select();

生成的SQL语句是:

SELECT DISTINCT name FROM think_user

示例如下:

显示的是这样的

在加入distinct的话:

显示结果为

下面为贴出来的代码

$offernum = M('offer')->distinct(true)->where('order_id='.$order_id)->field('user_id,number')->select();
dump($offernum);

推荐学习:《PHP视频教程》

以上就是thinkphp中distinct的用法是什么的详细内容,

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/731448.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-27
下一篇 2022-04-27

发表评论

登录后才能评论

评论列表(0条)

保存