Ion Auth/CodeIgniter致命错误:未定义方法Ion_auth::get_user()被调用


Ion Auth/CodeIgniter Fatal Error: Undefined method Ion_auth::get_user() called

在试图访问我的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

图书馆扩展我正在使用离子认证: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 Library Line 88段:http://pastie.org/private/mhgwdzjyhatwsdrux4gqpa

CRUD模型:http://pastie.org/private/m2nhfqzabdsx5eiz6xqupw

事件模型:http://pastie.org/private/b6ksjoowl7wde9errow

共享模型:http://pastie.org/private/f741jfnf8o2l5oxphnrl5w

嗯,我也遇到过同样的事情。在这个库的最新版本中,Ben Edmunds使用了php魔法方法__call(),这样你就不必使用常规语法$this->ion_auth_model->method()来调用模型的方法,而是使用$this->ion_auth->method(),就好像它是一个属于库的方法。

但是,实际上,那个方法属于模型。因此,如果您查看模型,您将看到没有get_user()方法(库中也没有!),或者至少在我谈论的版本(最新的或之前的版本)中没有。我在一两周前下载了一个新版本)。我认为他提供的文档中有一些错误(尽管他所做的总体工作非常棒,向Ben致敬)。

您可以尝试使用user()模型方法,它应该产生相同的结果(它在功能上更接近)。因此,调用$this->ion_auth->user(),看看是否符合您的需求。

编辑

澄清……而不是这个…

$this->end_user = $this->ion_auth->current()->row();

这样做……

$this->end_user = $this->ion_auth->user()->row();