Trying to get property of non-object错误

浏览:17102 发布日期:2016/08/08 分类:ThinkPHP5专区
错误:Trying to get property of non-object

thinkphp版本:ThinkPHP 5.0 RC4版本

控制器代码:
class StudentController extends Controller
{
public function index()
{
$students = Student::paginate(2);
$this->assign('students', $students);
return $this->fetch();
}
}

模型代码:
class Student extends Model
{
public function Klass()
{
return $this->belongsTo('klass','','','','FULL JOIN');
}
}

视图代码:
<td>{$student->klass->name}</td>
最佳答案
评论( 相关
后面还有条评论,点击查看>>