1

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

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

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

4

1 回答 1

2

嗯,同样的事情发生在我身上。在这个库的最新版本中,Ben Edmunds 使用了 php 魔术方法__call(),因此您不必使用常规语法调用模型的方法,$this->ion_auth_model->method()而是使用 instead $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();
于 2011-11-12T10:35:41.200 回答