//这是model层的查询方法
$subQuery = Db::table('wx_member')
->alias('t1')
->join(['wx_member'=>'t2'],'t1.pid=t2.id')
->where('t2.pid',$id)
->page($page,$limit)->select();
echo Member::getLastSql();
dump($subQuery);die;//打印的SQL
SELECT * FROM `wx_member` `t1` INNER JOIN `wx_member` `t2` ON `t1`.`pid`=`t2`.`id` WHERE `t2`.`pid` = '3' LIMIT 0,10array(2) {
[0] => array(21) {
["id"] => int(4)
["openid"] => string(28) "oLlgi0s4rt1cXgDnu8OVhkH4Soa0"
["nickname"] => string(6) "飞飞"
["sex"] => int(1)
["language"] => string(5) "zh_CN"
["city"] => string(6) "梅州"
["province"] => string(6) "广东"
["country"] => string(6) "中国"
["headimgurl"] => string(131) "http://thirdwx.qlogo.cn/mmopen/vi_32/eU0nWlXaIfe5bHX5OZMJBxQB2AeDqicKVyQBWjVBeQQjvp9ASlhyibsFc3grcPzt6nr3bViaqCHEYx4OBq8uEicePQ/132"
["pid"] => int(3)
["login_time"] => int(1541513852)
["login_ip"] => string(12) "116.7.11.111"
["code"] => string(32) "071xdJNG0cnHqj27e3NG0VmRNG0xdJND"
["state"] => string(6) "123456"
["phone"] => NULL
["is_verify"] => int(0)
["phone_verify_time"] => NULL
["privilege"] => NULL
["cj_count"] => int(0)
["cj_max_count"] => int(4)
["is_wxfx"] => int(1)
}
[1] => array(21) {
["id"] => int(4)
["openid"] => string(28) "oLlgi0s4rt1cXgDnu8OVhkH4Soa0"
["nickname"] => string(6) "飞飞"
["sex"] => int(1)
["language"] => string(5) "zh_CN"
["city"] => string(6) "梅州"
["province"] => string(6) "广东"
["country"] => string(6) "中国"
["headimgurl"] => string(131) "http://thirdwx.qlogo.cn/mmopen/vi_32/eU0nWlXaIfe5bHX5OZMJBxQB2AeDqicKVyQBWjVBeQQjvp9ASlhyibsFc3grcPzt6nr3bViaqCHEYx4OBq8uEicePQ/132"
["pid"] => int(3)
["login_time"] => int(1541513852)
["login_ip"] => string(12) "116.7.11.111"
["code"] => string(32) "071xdJNG0cnHqj27e3NG0VmRNG0xdJND"
["state"] => string(6) "123456"
["phone"] => NULL
["is_verify"] => int(0)
["phone_verify_time"] => NULL
["privilege"] => NULL
["cj_count"] => int(0)
["cj_max_count"] => int(4)
["is_wxfx"] => int(1)
}
} 最佳答案