1. 程式人生 > >tp3.2 複合查詢

tp3.2 複合查詢

複合查詢相當於封裝了一個查詢條件,然後併入原來的查詢條件之中    比如 or 與 and 都需要的場景下

$where['title']  = array('like', '%預設名稱%');
$where['title']  = array('like','%thinkphp%');
$where['_logic'] = 'OR';
$map['_complex'] = $where;   //
$map['type']  = array('EQ',1);

生成條件是

( type = 1) AND ( ( title like '%預設名稱%') OR ( title like '%thinkphp%') )

另一種寫法

$where['type'] = array('EQ',1);
$where['_string'] = ' (title like "%預設名稱%")  OR ( title like "%thinkphp") ';

結果同上

注意:  tp3裡 在寫多where時 字串條件只能寫一個 ; 要結合陣列格式條件;