问题遇到的现象和发生背景
thinkphp5.0 php7.2 nginx1.20 mysql5.7
问题相关代码,请勿粘贴截图
$twhere1 = [['pipeitime','between',['1648656000','1648742359']],['shanghu_name','in','baidu123'],['status','=',6]];
$twhere2 = [['pipeitime','between',['1648656000','1648742359']],['shanghu_name','in','baidu123'],['status','=',6]];
/****************************/
$twhere1[] = ['class','=',1];
$twhere2[] = ['class','=',2];
$roborder = new \app\admin\model\Roborder();
echo '<hr>';
$today1 = $roborder->receivePayment($twhere1);
echo 'sql1:',$roborder->getLastSQL();
$today1 = array_column($today1,null,'shanghu_name');
echo '<hr>';
$today2 = $roborder->receivePayment($twhere2);
echo 'sql2:',$roborder->getLastSQL();
echo '<br>';
运行结果及报错内容
sql1:SELECT sum(price) tot,shanghu_name FROM ysk_roborder
WHERE pipeitime
BETWEEN 1648656000 AND 1648742359 AND shanghu_name
= 'baidu123' AND status
= 6 AND class
= 1 GROUP BY shanghu_name
sql2:SELECT sum(price) tot,shanghu_name,sum(price) tot,shanghu_name FROM ysk_roborder
WHERE pipeitime
BETWEEN 1648656000 AND 1648742359 AND shanghu_name
= 'baidu123' AND status
= 6 AND class
= 1 AND pipeitime
BETWEEN 1648656000 AND 1648742359 AND shanghu_name
= 'baidu123' AND status
= 6 AND class
= 2 GROUP BY shanghu_name
我的解答思路和尝试过的方法
两次 new 就不会出现
我想要达到的结果
只new 一次,就可以不用上一次执行的where