Home > Backend Development > PHP Tutorial > How to use fuzzy query in tp framework

How to use fuzzy query in tp framework

不言
Release: 2023-02-28 17:38:01
Original
3963 people have browsed it

$con=$_POST['con'];
        
        $User = M("Activity"); // 实例化User对象
        
        $User->where("LIKE")->select();
Copy after login
Copy after login

How to write the query word in the middle of where() is $con? Please give me an answer

Reply content:

$con=$_POST['con'];
        
        $User = M("Activity"); // 实例化User对象
        
        $User->where("LIKE")->select();
Copy after login
Copy after login

How to write the query word in the middle of where() is $con? Please give me an answer

$con=$_POST['con'];
        
$User = M("Activity"); // 实例化User对象

$data['con'] = array('like', "%$con%");
        
$User->where($data)->select();
Copy after login

This question is relatively elementary. I suggest you take a look at tp’s model about query. document. When the ability reaches a certain level, let's take a look at the code implementation of the TP model. Just go to thinkphp official documentation on Baidu and view the section about querying the model.

The brother on the first floor just saw the invitation and I’m sorry. The brother on the first floor answered perfectly. Just solve it and learn from each other

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template