从 codeigniter 中的模型访问控制器(方法)

发布于 2025-01-03 09:38:18 字数 223 浏览 0 评论 0原文

我无法从模型访问方法。

我尝试过执行以下操作:

$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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

神魇的王 2025-01-10 09:38:18

我相当确定(阅读:大约 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文