TP3.2之WHERE组合条件处理
生活随笔
收集整理的這篇文章主要介紹了
TP3.2之WHERE组合条件处理
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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();?
轉載于:https://www.cnblogs.com/xuzhengzong/p/7168772.html
總結
以上是生活随笔為你收集整理的TP3.2之WHERE组合条件处理的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Pointcut is not well
- 下一篇: html5有哪些新特性、移除了那些元素?