Tencent / Biny

Biny is a tiny, high-performance PHP framework for web applications
BSD 3-Clause "New" or "Revised" License
1.69k stars 258 forks source link

单表的 merge筛选器变成and查询了 #96

Closed itbirds closed 5 years ago

itbirds commented 5 years ago

调用内容如下: $this->testDAO->merge(['id'=>1,'is_del'=>1])->update(['test'=>1111]);

框架调用过程如下:

  1. SingleDAO.php 的merge方法,这里实例化了一个SingleFilter类 public function merge($cond=[]) { return $cond ? new SingleFilter($this, $cond, "or") : $this; }

2.SingleFilter类继承Filter类,实例化传的参数调用的是Filter里面的构造方法

  1. 在构造方法里面,有type和link二个变量来影响,查询是and 还是 or查询,内容如下:

elseif (is_array($filter)){ if ($cond){ $this->conds = [[$type => [$cond, [$link=>[[self::valueKey => $filter]]]]]]; } else { $this->conds = [[$link => [[self::valueKey => $filter]]]]; } }

问题是:$cond没有传值是null,所以走else判断,直接走了link变量的值,但是link默认是and,而且构造方法并未传这个参数值

billge1205 commented 5 years ago

的确是个bug 非常感谢 已修复

itbirds commented 5 years ago

没事不客气