thinkphp5 InvalidArgumentException:

浏览:122 发布日期:2019/05/15 分类:ThinkPHP5专区 关键字: thinkphp5 InvalidArgumentException
thinkphp5关联模型,当关闭调试功能运行正常 打开调试就报错 InvalidArgumentException: property not exists:app\index\model\PublicUsers->factory in D:\phpweb\lzbigdata\thinkphp\library\think\Model.php on line 337,请问什么原因,

代码如下(模型文件):
<?php
namespace app\index\model;
use think\Model;
class PublicUsers extends Model
{
public function factory()
{
return $this->hasOne('PublicFactorys','id','factoryid');
}
public function partment()
{
// 用户HAS ONE档案关联
return $this->hasOne('PublicPartments','id','partmentid');
}
public function author()
{
// 用户HAS ONE档案关联
return $this->hasOne('PublicAuthors','id','authorid');
}
public function role()
{
// 用户HAS ONE档案关联
return $this->hasOne('PublicRoles','id','roleid');
}
public function fileauthor()
{
// 用户HAS ONE档案关联
return $this->hasOne('FileFileAuthors','id','fileauthorid');
}
public function specialty()
{
// 用户HAS ONE档案关联
return $this->hasOne('PublicSpecialtys','id','specialtyid');
}

}

控制器文件:

<?php
namespace app\index\controller;
use think\Controller;
use think\Db;
use think\Cookie;
use think\Session;
use think\Url;
use think\Request;
use app\index\model\PublicUsers;

class Login extends Controller
{
function __construct()
{
parent::__construct();
}
public function index()
{
$param = $this->request->param();
if(!empty($param)){
$logname = trim($param['logname']);
$password = md5(trim($param['password']));
$list = PublicUsers::where(['logname'=>$logname,'password'=>$password])->find();
if(!empty($list)){
echo $list['factory']['factoryname'];
}
}

}
}
最佳答案
评论( 相关
后面还有条评论,点击查看>>