从 codeigniter 中的模型访问控制器(方法)
我无法从模型访问方法。
我尝试过执行以下操作:
$CI= & get_instance();
$array = $CI->buildDateArray($this->session->userdata('dates'), $dateFormat);
但它不属于该方法。
请指教,
谢谢。
I'm having trouble accessing a method from a model.
I have tried doing the following:
$CI= & get_instance();
$array = $CI->buildDateArray($this->session->userdata('dates'), $dateFormat);
but it doesn't go into that method.
Please advise,
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相当确定(阅读:大约 80%)CI 不执行 HMVC,因此您无法从模型向控制器发出请求。
我会仔细检查您的应用程序流程,因为通常您不应该这样做(通常)。如果您确实需要,请考虑 http://codeigniter.com/wiki/Modular_Extensions__-_HMVC -不确定它是否有任何好处,但看起来它应该可以完成这项工作。
如果您决定为您的应用程序切换到 Kohana 或 Fuel,则会获得奖励积分,它们更难获得,但功能更强大:P
I'm fairly sure (read: about 80%) that CI doesn't do HMVC, so you can't make requests to controllers from your model.
I'd have a good hard look at the flow of your application, because normally you shouldn't be doing that (normally). If you really need to, consider http://codeigniter.com/wiki/Modular_Extensions_-_HMVC - not sure if it's any good, but it looks like it should do the job.
Bonus points if you decide to switch to Kohana or Fuel for your app, they're harder to pick up, but more powerful :P