1、条件都是int类型:

$User->where('type=1 AND status=1')->select();

2、条件包含字符串类型:

使用3.1以上版本的话,使用字符串条件的时候,建议配合预处理机制,确保更加安全,

$Model->where("id=%d and username='%s' and xx='%f'",$id,$username,$xx)->select();

或者:

$Model->where("id=%d and username='%s' and xx='%f'",array($id,$username,$xx))->select();

3、数组条件:

$User = M("User"); // 实例化User对象
$map['name'] = 'thinkphp';
$map['status'] = 1;
// 把查询条件传入查询方法
$User->where($map)->select(); 

4、表达式查询:比如大于,小于,不等于等

$map['a'] = array('gt',1);
$where['b'] = 1;
$Model->where($map)->where($where)->where('status=1')->select();

 

相关文章:

  • 2021-07-14
  • 2021-11-22
  • 2022-01-22
  • 2021-09-28
  • 2022-12-23
  • 2021-11-19
  • 2022-12-23
  • 2022-01-07
猜你喜欢
  • 2022-12-23
  • 2021-05-21
  • 2022-12-23
  • 2022-12-23
  • 2021-04-02
  • 2021-09-08
  • 2022-12-23
相关资源
相似解决方案