且构网

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

错误:SQLSTATE [42000]:语法错误或cakePHP的访问冲突

更新时间:2022-01-18 21:24:30

通常,如果发生此错误,则您没有模型实例,但是您正在使用的应用程序模型实例.该应用程序模型实例没有add()方法,而是直接使用add()查询数据库.

usually, if this error happens, you don't have the model instance, but an app model instance you work on. the app model instance doesnt have the add() method and directly queries the db with add().

,因此请确保正确包含您的模型.因为您没有向我们展示代码,您如何调用该方法(以及如何使模型对控制器可用),但是我无法提供任何具体建议.

so make sure your model is properly included. since you didnt show us the code how you call the method (and how you make the model available to the controller) I cannot offer any concrete advice, though.

如果您手动添加它:

$this->ModelName = ClassRegistry::init('ModelName');