orm这样使用会导致内存泄露吗

小叽叽叽叽

大量where的用这种方法会导致内存泄露吗,我个人感觉不会,因为每次都会重新赋值给builder的,但是我去GPT问他说会,我想问下大佬这方法会不会泄露

trait BaseFilter
{
    public $request;
    public $builder;

    public function scopeFilter($query, array $validated)
    {
        $this->builder = $query;

        foreach ($validated as $name => $value) {
            if (method_exists($this, $name) && !empty($value)) {
                call_user_func_array([$this, $name], array_filter([$value]));
            }
        }
        return $this->builder;
    }
}
675 1 0
1个回答

walkor

不会

🔝