当前位置:编程学习 > asp >>

ThinkPHP 查询where条件的like写法

多种写法ThinkPHP 查询where条件的like写法


$where=[

'type'=>2,

'id'=>array('eq',1), //id=1

'n_yizuotu|n_zzzyk'=>array('like', "%{$key}%", 'or'),  

'content'=>array('like',"{$key}%")   //特别注意 变量是 双引号

];


$rs = Db::name('zzzyk')->where($where)->find();


同时查询表中 n_yizuotu 和 n_zzzyk 两个字段中是否有包含关键词 $key


TP5 where多条件查询和 ThinkPHP运算符 与 SQL运算符 对照表


$rs=Db::name('zzzyk')->where('id',$id)->where($title,'like',"%{$key}%")->order('id desc')->limit($limit)->page($page)->select();  


CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,