Cannot use think\model\Collection as Collection because the name is already in use// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
namespace think;
use InvalidArgumentException;
use think\db\Query;
use think\Exception\ValidateException;
use think\model\Collection;
use think\model\Relation;
use think\model\relation\BelongsTo;
use think\model\relation\BelongsToMany;
use think\model\relation\HasMany;
use think\model\relation\HasManyThrough;
use think\model\relation\HasOne;
use think\model\relation\MorphMany;
use think\model\relation\MorphTo;描述:已在项目 admin/model/product 下面建立模型 product,在控制器A中的test方法中调用 模型product 的 cat 方法,此时一切正常,在A控制器中的B方法调用 模型product 的 cat 方法,直接报上述错误,但是本人并没有在A控制器和product模型中建立任何以Collection 命名的函数。但是调用就是出错了,有没有遇到同样情况的童鞋啊?求大神解答,指点一二补充: 原因之一:我在test方法中没有使用db(),加上db()之后就会报上述的错误,那么问题来了,为什么使用了db()就会报错呢?
最佳答案