两种写法导致执行结果不一样

浏览:117 发布日期:2022/10/02 分类:ThinkPHP6专区 关键字: tp6
$same = self::whereBetweenTime("complete_time",$firstDay,$lastDay)->where('install_status','complete')
                                                                        ->where('handle_admin_id=receiving_admin_id')
                                                                        ->where('handle_admin_id',$adminId)
                                                                        ->where('profit_amount','>',0)
                                                                        ->value("sum(`total_amount`-`refund_amount`)");
        $different = self::whereBetweenTime("complete_time",$firstDay,$lastDay)->where('install_status','complete')
                                                                            ->where("handle_admin_id<>receiving_admin_id and (handle_admin_id={$adminId} or receiving_admin_id={$adminId})")
                                                                            ->where('profit_amount','>',0)
                                                                            ->value("sum(`total_amount`-`refund_amount`)");
这么写
->where('handle_admin_id=receiving_admin_id')
和这么写
->where('handle_admin_id','receiving_admin_id')
生成的sql没啥区别,可是执行结果就是
->where('handle_admin_id','<>','receiving_admin_id')的结果。
这个->where('handle_admin_id','receiving_admin_id')->fetchSql()
生成sql在mysql的执行结果又没错,但是就是用tp model执行的结果不正确。有遇到类似情况吗?
最佳答案
评论( 相关
后面还有条评论,点击查看>>