简体   繁体   English

CakePHP在同一控制器中操纵多个模型

[英]CakePHP Manipulate more than one models in the same controller

  1. I created two plugins in the CakePHP, and both of them have the same named model, eg, plugin1.mod and plugin2.mod. 我在CakePHP中创建了两个插件,它们都具有相同的命名模型,例如,plugin1.mod和plugin2.mod。
  2. In the two models, defined the same named method, eg, mymethod. 在这两个模型中,定义了相同的命名方法,例如mymethod。
  3. Now, I have a controller in my main program. 现在,我的主程序中有一个控制器。 Then, use ClassRegistry::init to initialize plugin1 and can call plugin1.mod without problem. 然后,使用ClassRegistry :: init初始化plugin1并可以毫无问题地调用plugin1.mod。

Problem: 问题:

When I use ClassRegistry::init to initialize plugin2 and call the plugin2.mod, it is calling plugin1.mod! 当我使用ClassRegistry::init初始化plugin2并调用plugin2.mod时,它正在调用plugin1.mod! Can somebody tell me what wrong here is? 有人可以告诉我这里有什么问题吗?

Thank you. 谢谢。

in 2.0 this is not possible (anymore). 在2.0中,这是不可能的了。 class paths are cached (inside App class) and therefore can use a class name only once. 类路径被缓存(在App类内部),因此只能使用一次类名称。

You need to use different class names. 您需要使用不同的类名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM