Calling AppModel function in AppController for cakephp

最后都变了- 提交于 2019-12-05 08:18:01

All your models should inherit from AppModel, so why not call $this->AnyModel->get_some_cool_data($term); instead? AppModel should be pretty much be an abstract class anyways -- you pretty much never want to instantiate it, you just use as a base class.

Also, that should be $useTable = false; not $usesTable. Remember that, again, all your models should inherit from AppModel, so all your models will end up not using the database as well, which is probably the source of your errors.

To solve this for me, the solution that worked but I am unsatisfied with is to place these functions in the AppModel and then call them from any model like so:

$this->WhatEverModelIAmIn->the_general_function_I_need($some_argument);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!