0
在運行笨我有以下錯誤:
A PHP Error was encountered Severity: Notice Message: Undefined property: Social::$social_model Filename: controllers/social.php Line Number: 10
請告訴我請問我的代碼有什麼幫助嗎?
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();
}
// ....
}
應該是'如果($查詢== $ this' –
我嘗試過,但它還沒有工作:( –
您的代碼並不顯示社會和Si之間的任何關係te_model。事實上,你是指它在社會social_model,但你永遠不任何實例作爲這個 - $> social_model。如果你不聲明參數social_model,那麼你就不能使用它。 –