Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use distinct in thinkphp

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains how to use distinct in thinkphp. Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "how to use distinct in thinkphp"!

In thinkphp, the distinct() method is used to remove duplicate values and return a unique value, and the argument to the distinct method is a Boolean value with the syntax "$Model->distinct(Boolean argument)->field ('name ')->select();".

Operating environment: Windows 10 system, ThinkPHP3.2 version, Dell G3 computer.

What is the use of distinct in thinkphp

TP distinct () is mainly used to remove duplicate values

The DISTINCT method is used to return unique values.

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

The SQL statements generated are:

SELECT DISTINCT name FROM think_user

Below is the code posted.

$offernum = M('offer')->distinct(true)->where('order_id='.$ order_id)->field ('user_id, number')->select();dump($offernum); At this point, I believe that everyone has a deeper understanding of "how to use distinct in thinkphp", so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report