我正在使用 codeiginter,基本上我需要OR ()而不是AND ()在使用group_start(). 这可能吗?
我需要生产的是
WHERE (u.location LIKE '%?%' OR (u.long BETWEEN ? AND ? AND u.lat BETWEEN ? AND ?)) AND u.active=1
Run Code Online (Sandbox Code Playgroud)
我目前在做什么
$this->db->group_start()
->like('u.location',$selector['text']);
if(isset($geo)){
$this->db->group_start();
$this->db->where('u.long >',$geo->long)
->where('u.long <',$geo->longmax)
->where('u.lat >',$geo->lat)
->where('u.lat <',$geo->latmax)
->group_end();
}
$this->db->group_end();
Run Code Online (Sandbox Code Playgroud)
这会产生什么
WHERE ( `u`.`location` LIKE '%?%' ESCAPE '!' AND ( `u`.`lat` < ? AND `u`.`lat` > ? AND `u`.`long` < ? AND `u`.`long` > ? ) )
Run Code Online (Sandbox Code Playgroud)
谢谢您的帮助!
| 归档时间: |
|
| 查看次数: |
9661 次 |
| 最近记录: |