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-03-04 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

  • How to use css to realize the Animation effect of Water pattern Diffusion

    Editor to share with you how to use css to achieve watermark diffusion animation effect, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

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

    12
    Report