douyinmian8151 2014-02-19 20:33
浏览 51

遇到PHP错误严重性:通知消息:未定义属性:Social :: $ social_model文件名:controllers / social.php行号:10

while running the codeigniter I have a following error:

A PHP Error was encountered Severity: Notice Message: Undefined property: Social::$social_model Filename: controllers/social.php Line Number: 10

Whats wrong with my code any help please?

controllers/social.php

class Social extends CI_Controller {

    public function index(){

            $data = array();
            $this->load->view('header.php');
            $this->load->view('staffs/content.php');
            if ($query = $this-> social_model -> get_records()) // **[line 10]**
            {
                $data['records'] = $query;
            }

            $this->load->view('social/content.php', $data); 
            $this->load->view('footer.php');
        }

   // ....
}

models/social_model.php

<?php
class  social_model extends CI_Model{

    function get_records()
    {
        $query = $this->db->get('admins');
        return $query -> result();
    }

   // ....
}
  • 写回答

1条回答 默认 最新

  • donglinxin8765 2018-02-13 11:07
    关注

    You must load model:

    $this->load->model('social_model');
    
    评论

报告相同问题?

悬赏问题

  • ¥15 制裁名单20240508芯片厂商
  • ¥20 易康econgnition精度验证
  • ¥15 线程问题判断多次进入
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接