问题遇到的现象和发生背景
批量新增
遇到的现象和发生背景,请写出第一个错误信息
method not exist:think\db\Query->saveAll
用代码块功能插入代码,请勿粘贴截图。 不用代码块回答率下降 50%
$res = Db::name('invoice_rate')->saveAll();//在model里面使用saveAll
//这是报错
[0] Exception in Query.php line 200
method not exist:think\db\Query->saveAll
return call_user_func_array([$this, 'where'], $args);
} elseif ($this->model && method_exists($this->model, 'scope' . $method)) {
// 动态调用命名范围
$method = 'scope' . $method;
array_unshift($args, $this);
call_user_func_array([$this->model, $method], $args);
return $this;
} else {
throw new Exception('method not exist:' . ($this->model ? get_class($this->model) : static::class) . '->' . $method);
}
}
/**
* 扩展查询方法
* @access public
* @param string|array $method 查询方法名
* @param callable $callback
* @return void
运行结果及详细报错内容
[0] Exception in Query.php line 200
method not exist:think\db\Query->saveAll
return call_user_func_array([$this, 'where'], $args);
} elseif ($this->model && method_exists($this->model, 'scope' . $method)) {
// 动态调用命名范围
$method = 'scope' . $method;
array_unshift($args, $this);
call_user_func_array([$this->model, $method], $args);
return $this;
} else {
throw new Exception('method not exist:' . ($this->model ? get_class($this->model) : static::class) . '->' . $method);
}
}
/**
* 扩展查询方法
* @access public
* @param string|array $method 查询方法名
* @param callable $callback
* @return void
我的解答思路和尝试过的方法,不写自己思路的,回答率下降 60%
在当前问题上面进行了一系列的测试,save isupdate saveall等等都是会报类似的错误