Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use distinct in thinkphp

Shulou Source: shulou.com Published: 2022-05-31 19:47:51 10月03日 Update

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!

Tags: Methods different content parameters Boolean learning practical deeper code interest practicality practical easy to operate more friends environment usefulness computer system website Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Shulou Technology Microsoft Xiaomi Huawei