首页 > 后端开发 > 正文

thinkphp 关联模型怎么进行条件查询

2024-12-29 23:59:21 | 我爱编程网

我爱编程网小编给大家带来了thinkphp 关联模型怎么进行条件查询相关文章,一起来看一下吧。

本文目录一览:

thinkphp 关联模型怎么进行条件查询

thinkphp where有多个条件进行复合查询,关系为or,代码如下

请参考thinkphp开发手册的查询语言一节,可以有不同写法,我这里写一种供你参考:

$where1=array(
    'Key'=>array('like','zt'.'%'),
    'code'=>'02'
);
$where=array(
    'modes'=>1,
    'Key'=>array('like','tm'.'%'),
    'code'=>'02',
    '_complex'=>$where1, // 复合查询
    '_logic'=>'or'       // 关系为or
);
// 查询语句
$mysql=M('Mysql')->where($where)->select();

thinkphp 关联模型怎么进行条件查询我爱编程网

thinkphp map查询条件

你指的是条件查询吧?格式是这样的
$map['id'] = 1;//相当于 where id=1
或者 $map['id'] = array('eq',1);
而'不等于'是这样表达 $map['id'] = array('neq',1);
当然,条件可以复合加:如
$map['id'] = 1;
$map['cid']=2;
等同于 where id=1 and cid=2

thinkphp 关联模型怎么进行条件查询

我爱编程网(https://www.52biancheng.com)小编还为大家带来thinkphp 关联模型怎么进行条件查询的相关内容。

$task = D("task a");
$list = $task->join('think_user b on a.poster=b.id')->where($where)->field('a.*,b.username,b.name,b.kid')->order($order )->limit($p->firstRow.','.$p->listRows)->select();
$where可以是数组也可以是字符串

以上就是我爱编程网小编给大家带来的thinkphp 关联模型怎么进行条件查询,希望能对大家有所帮助。更多相关文章关注我爱编程网:www.52biancheng.com

免责声明:文章内容来自网络,如有侵权请及时联系删除。
与“thinkphp 关联模型怎么进行条件查询”相关推荐