更新时间:2023-02-12 08:52:17
Location 模型的类名应该是 Location
,而不是 LocationModel
.
The class name of your Location model should be Location
, not LocationModel
.
因此,CakePHP 将为 Locations 数据库表生成一个通用"模型,并使用该模型而不是您自己的模型.因为这个泛型模型没有没有有get()
方法,它会将get
作为SQL语句执行,导致错误
Because of this, CakePHP will generate a 'generic' model for the Locations database table and use that model instead of your own model. Because this generic model does not have a get()
method, it will execute get
as a SQL statement, causing the error
此外,在模型内部,您不应该使用 $this->Location->query();
,而应使用 $this->query();
代码>
Also, inside the Model, you should not use $this->Location->query();
, but simply $this->query();