Ion Auth/CodeIgniter 致命错误:调用了未定义的方法 Ion_auth::get_user()
尝试访问我的 planner.php 和 shared.php 控制器时收到此致命错误。有什么想法吗?
Fatal error: Uncaught exception 'Exception' with message 'Undefined method Ion_auth::get_user() called' in
/application/libraries/Ion_auth.php:88 Stack trace: #0
/application/core/MY_Controller.php(50): Ion_auth->__call('get_user', Array) #1
/application/core/MY_Controller.php(50): Ion_auth->get_user() #2
/application/controllers/user/planner.php(9): Common_Auth_Controller->__construct() #3
/system/core/CodeIgniter.php(288): Planner->__construct() #4 /index.php(202): require_once('/Users/lrussell...') #5 {main} thrown in/application/libraries/Ion_auth.php on line 88
我用于 Ion Auth 的库扩展: http://jondavidjohn.com/blog/2011/01 /scalable-login-system-for-codeigniter-ion_auth
规划器控制器: http://pastie.org/private/wc1bq6eiqb9hn8iubwdgq
共享控制器: http://pastie.org/private/uj3ta8dw3jl7kqxizs9n1a
Ion_auth 库第 88 行段: http://pastie.org/private/mhgwdzjyhatwsdrux4gqpa
CRUD 模型: http://pastie.org/private/m2nhfqzabdsx5eiz6xqupw
Receiving this fatal error when trying to access my planner.php and shared.php controllers. Any thoughts?
Fatal error: Uncaught exception 'Exception' with message 'Undefined method Ion_auth::get_user() called' in
/application/libraries/Ion_auth.php:88 Stack trace: #0
/application/core/MY_Controller.php(50): Ion_auth->__call('get_user', Array) #1
/application/core/MY_Controller.php(50): Ion_auth->get_user() #2
/application/controllers/user/planner.php(9): Common_Auth_Controller->__construct() #3
/system/core/CodeIgniter.php(288): Planner->__construct() #4 /index.php(202): require_once('/Users/lrussell...') #5 {main} thrown in/application/libraries/Ion_auth.php on line 88
Library Extension I'm Using for Ion Auth:
http://jondavidjohn.com/blog/2011/01/scalable-login-system-for-codeigniter-ion_auth
Planner Controller:
http://pastie.org/private/wc1bq6eiqb9hn8iubwdgq
Shared Controller:
http://pastie.org/private/uj3ta8dw3jl7kqxizs9n1a
Ion_auth Library Line 88 Segment:
http://pastie.org/private/mhgwdzjyhatwsdrux4gqpa
CRUD Model:
http://pastie.org/private/m2nhfqzabdsx5eiz6xqupw
Events Model:
http://pastie.org/private/b6ksjoowl7wde9errow
Shared Model:
http://pastie.org/private/f741jfnf8o2l5oxphnrl5w
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯,同样的事情也发生在我身上。在该库的最新版本中,Ben Edmunds 使用了 php 魔术方法
__call()
,这样您就不必使用常规语法$this->ion_auth_model 来调用模型的方法->method()
但使用$this->ion_auth->method()
,就好像它是属于库的方法一样。但实际上,该方法属于模型。因此,如果您查看模型,您会发现没有
get_user()
方法(库中也没有!),或者至少在我谈论的版本中(最新的或之前我一两周前下载的新副本)。我认为他提供的文档中有一些错误(尽管他所做的整体工作很棒,向 Ben 致敬)。
您可以尝试使用
user()
模型方法,它应该产生相同的结果(它的功能更接近)。因此,请调用$this->ion_auth->user()
并查看是否符合您的需求。编辑
为了澄清...而不是这个...
这样做...
Uhm, it happened to me the same exact thing. In the latest releases of this library, Ben Edmunds used php magic method
__call()
so that you don't have to call a model's method by using the regular syntax$this->ion_auth_model->method()
but using instead$this->ion_auth->method()
, as if it was a method belonging to the library.But, actually, that method belongs to the model. So, if you go have a look at the model, you'll see that there's no
get_user()
method (nor is there in the library!), or at least in the version I talk about (the latest or the one just before. I downloaded a fresh copy one or two weeks ago).I think there are some errors in the documentation he provided (though the overall work he did is awesome, kudos to Ben).
You can try using the
user()
model method, which should yield to the same result (it's the closer in functionality). So call$this->ion_auth->user()
and see if that fits your needs.EDIT
To clarify... instead of this...
do this...