且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在CakePHP中创建自定义MySQL查询?

更新时间:2023-02-12 08:52:23

位置,而不是 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();