-
Notifications
You must be signed in to change notification settings - Fork 257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在同一个方法中调用两个不同的$model 时, 后面的那个无法正常调用 #139
Comments
不应该有这个问题 lib\models\Models.php 这个文件有改过吗? |
我好像知道了 你的redis model对象 和 user model对象是不是用了同一个单例对象维护的? |
App::$model->redis 本质是 返回了 app\model\redis::init() |
原来还要写 init() 的。。。 |
嗯 优先init() 其次 __construct 都不写的话 就走到了基类的__construct 大概就是这个原因导致的 |
我创建了两个 model,一个 redis 缓存相关, 一个 user 用户相关。
经过测试,如果只单独使用其中一个,没有问题,但如果两个混合使用,后面的那个model无法正常定位到方法。
如果把前面的 $data = App::$model->redis->GetWikiDataForPath($path); 注释掉,
后面的 $user_id = App::$model->user->GetUserId(); 就能正常获取到用户id了,
但如果前面的存在,后面的就会报错找不到 GetUserId 方法,原因是因为它去 redis 里面找的 。
将两个方法反过来, 如果先用 App::$model->user 之后,再调用 App::$model->redis ,它则会去 user 里面去找 redis 的方法,
The text was updated successfully, but these errors were encountered: