Tp3.2 复合查询
我们常常有这样的需求,比如搜索。
搜索出,标题,子标题,内容中包含某某关键字。
这就要and,or结合使用了。
$where = ['is_show'=>1,'status'=>1]; // 默认查询条件
// 查询条件
if ($keywords = $_POST['keywords']) {
$map['title'] = ['like','%'.$keywords.'%'];
$map['age'] = ['like',$keywords.'%'];
$map['address'] = ['like','%'.$keywords.'%'];
$map['_logic'] = 'or';
$where['_complex'] = $map;
}
巧妙的解决了这个问题,或者你通过字符串拼接也可以。
SELECT `id`,`title`,`title_img`,`age`,`gender`,`address` FROM `tf_student` WHERE `is_show` = 1 AND `status` = 1 AND ( `title` LIKE \'%20%\' OR `age` LIKE \'20%\' OR `address` LIKE \'%20%\' ) ORDER BY id desc LIMIT 0,2
Tp3.2 复合查询的更多相关文章
- tp3.2 复合查询or
tp3.2 复合查询or $where['goods_name'] = array("like","%$q%");$where['goods_sn'] = ar ...
- [tp3.2.1]查询(2)
<?php namespace Home\Controller; use Think\Controller; use Think\Model; class QueryController ext ...
- Hibernate的几种查询方式-HQL,QBC,QBE,离线查询,复合查询,分页查询
HQL查询方式 这一种我最常用,也是最喜欢用的,因为它写起来灵活直观,而且与所熟悉的SQL的语法差不太多.条件查询.分页查询.连接查询.嵌套查询,写起来与SQL语法基本一致,唯一不同的就是把表名换成了 ...
- 彻底理解Oracle中的集合操作与复合查询
--Oracle中的复合查询 复合查询:包含集合运算(操作)的查询 常见的集合操作有: union: 两个查询的并集(无重复行.按第一个查询的第一列升序排序) union all:两个查询的并集(有重 ...
- Java中mongodb使用and和or的复合查询
在MongoDB的JAVA查询中对应这些问题 and查询 //条件 startsAt< curr and endsAt > curr long curr = new Date().getT ...
- thinkphp _complex 复合查询 where多个子组实现
SELECT * FROM `user` WHERE ( `mobile` = '13824653465' OR `nickname` = 'evan' OR `openid` = '14545-fd ...
- 【积累】LinqToSql复合查询结果转DataTable数据
最近的项目用到了大量的复合查询结果用于数据源,绑定到数据控件上. 为了方便,我们把它转换成DataTable的数据源形式.请看下面的示例: 1)思考自己需要的数据,然后组合,因此创建一个新的类: // ...
- Elasticsearch(7) --- 复合查询
Elasticsearch(7) ---复合查询 复合查询有:bool query(布尔查询).boosting query(提高查询).constant_score(固定分数查询).dis_max( ...
- Elasticsearch实现复合查询,高亮结果等技巧
一.Es的配置 实现es的全文检索功能的第一步,首先从与es进行连接开始,这里我使用的是es的5.x java api语法. public TransportClient esClient() thr ...
随机推荐
- HashMap和LinkedHashMap区别
import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; import java.uti ...
- Zynq ZC706 传统方式移植Linux -- 编译u-boot
我用的是zc706不是zed 基本思路是: 1.安装交叉编译工具(见 https://www.cnblogs.com/idyllcheung/p/10532654.html ) 2.下载xilinx ...
- linux apidoc的安装和使用
1.先去官网下载已编译好的安装包 以Centos7.4 64位为例, 下载地址: https://nodejs.org/dist/v8.1.2/node-v8.1.2-linux-x64.tar.xz ...
- JDK JRE JVM的区别
Jdk[Java Development ToolKit]就是java开发工具箱, JDK是整个JAVA的核心,里边包含了jre,它除了包含jre之外还包含了一些javac的工具类,把java源文件编 ...
- Linux进程内存分析pmap命令
转自: http://blog.csdn.net/u013982161/article/details/52654256 名称: pmap - report memory map of a proce ...
- 批处理:根据进程名称查询进程,如果有进程就输出up没有就输出donw
需求:windows系统上 根据进程名称查询进程,如果有进程就输出 up ,没有就输出 donw. ::Final interpretation is owned by chenglee ::@e ...
- 基础_模型迁移_CBIR_augmentation
在之前我们做过这样的研究:5图分类CBIR问题 各不相同的 5类的图形,每类100张 import numpy as npfrom keras.datasets import mnistimport ...
- 我的QML
1.键盘加Text import QtQuick 2.7 import QtGraphicalEffects 1.0 Rectangle{ width:; height:; color:"# ...
- LogStash Download
https://www.elastic.co/downloads/logstash 1.Download and unzip Logstash 2.Prepare a logstash.conf co ...
- 【ContextLoaderListener】Web项目启动报错java.lang.ClassNotFoundException: ContextLoaderListener
错误原因: 进入到tomcat的部署路径.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\下检查了一下,发现工程部署后在WE ...