php where嵌套查询,thinkphp _complex 复合查询 where多个子组实现

SELECT * FROM `user` WHERE ( `mobile` = '13824653465' OR `nickname` = 'evan' OR `openid` = '14545-fdes' ) AND ( `bind_seller` = 'fdaflj24214' OR `seller_type` = '1' ) AND ( `reg_time` < 12324568 AND `login_count` > 10 )

THINKPHP 数组where实现多个复合查询,例如上面的sql。查询官方手册,感觉无法实现。于是想到修改一下THINKPHP框架的DB类。

thinkphp 3.1 文件所在 \ThinkPHP\Lib\Core\Db.class.php

tthinkphp 3.2  \ThinkPHP\Library\Think\Db\Driver.class.php

修改这个方法

protected function parseThinkWhere($key,$val) {

$whereStr = '';

switch($key) {

case '_string':

// 字符串模式查询条件

$whereStr = $val;

break;

case '_complex':

case '_complex1': //增加多个case分支,支持多个符合 只查询

case '_complex2':

你可能感兴趣的:(php,where嵌套查询)