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

How to use fuzzy query in tp framework

不言
不言Original
2018-05-18 14:36:413939browse

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

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();

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();

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

Statement:
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