请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

php7中获取$this->getLoginUser()->bis_id 信息 报错解决方案

亲爱的小伙伴, 再8-13 门店管理本节中如果您的PHP版本是7.0以上的话,

再 app\bis\controller\Location.php文件中的

$bisId = $this->getLoginUser()->bis_id;

会有如下得报错信息:

Fatal error: app\bis\controller\Location::add(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "app\common\model\BisAccount" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition


php5不会存在这个问题, 我们需要做下修改:

修改方案如下:

1、找到:

app\bis\controller\Login.php

2、再定位到index方法

把 

$ret = model('BisAccount')->get(['username'=>$data['username']])修改为:

$ret = model('BisAccount')->get(['username'=>$data['username']])->toArray();   转化为数组,

然后把之前代码中获取对象里面的值 比如 $ret->status  修改为 $ret['status']

其他的自行修改 

3、然后在定位到 app\bis\controller\Location.php 

$bisId = $this->getLoginUser()->bis_id; 修改为 : $bisId = $this->getLoginUser()['bis_id'];



就没问题了。

正在回答 回答被采纳积分+3

1回答

提问者 singwa 2019-02-19 00:41:09

小伙伴记得关注

3 回复 有任何疑惑可以回复我~
  • 快两年了,老师还在维护课程问题,棒棒哒
    回复 有任何疑惑可以回复我~ 2019-05-06 09:18:57
  • 提问者 singwa 回复 慕少3988074 #2
    哈哈哈。
    回复 有任何疑惑可以回复我~ 2019-10-26 11:20:32
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信