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

来源:8-13 门店管理

singwa

2019-02-19

亲爱的小伙伴, 再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'];



就没问题了。

写回答

1回答

singwa

提问者

2019-02-19

小伙伴记得关注

3
2
singwa
回复
慕少3988074
哈哈哈。
2019-10-26
共2条回复

Thinkphp5.0仿百度糯米开发多商家电商平台

【毕设】BAT大牛亲授ThinkPHP 5.0,实战中学透新技能,应用于工作

2439 学习 · 1711 问题

查看课程