迷途的小子 2022-03-31 17:14 采纳率: 0%
浏览 25

thinkphp5.0 model 未重新new where 条件被重复利用

问题遇到的现象和发生背景

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

  • 写回答

2条回答 默认 最新

  • 掉头发的程序猿 2022-03-31 17:24
    关注

    静态调用 不new 不行吗.

    评论

报告相同问题?

问题事件

  • 创建了问题 3月31日

悬赏问题

  • ¥15 Coze智能助手搭建过程中的问题请教
  • ¥15 12864只亮屏 不显示汉字
  • ¥20 三极管1000倍放大电路
  • ¥15 vscode报错如何解决
  • ¥15 前端vue CryptoJS Aes CBC加密后端java解密
  • ¥15 python随机森林对两个excel表格读取,shap报错
  • ¥15 基于STM32心率血氧监测(OLED显示)相关代码运行成功后烧录成功OLED显示屏不显示的原因是什么
  • ¥100 X轴为分离变量(因子变量),如何控制X轴每个分类变量的长度。
  • ¥30 求给定范围的全体素数p的(p-2)/p的连乘积值
  • ¥15 VFP如何使用阿里TTS实现文字转语音?