需求:要求查询news表中title 中包含 bh 或者nk 的资讯
1)sql语句为
select id,title,keyword, from news where title like "%bh%" or titlelike "%nk%" ORDER BY add_time DESC limit 8
2)tp框架写法为
$where['title'] = array(['like', "%bh%"],['like',"%nk%",'or');
$data=M('news')
->field('id,title,keyword')
->where($where)
->order('add_time DESC')
->select();