CI 묻고 답하기

제목 이건 또 무슨 에러인지...
글쓴이 코드원 작성시각 2012/05/04 19:07:08
댓글 : 7 추천 : 0 스크랩 : 0 조회수 : 16746   RSS
 안녕하세요. 삽질하고 있는 초보입니다.

Call to a member function insert() on a non-object 

이런 에러 메시지는 어떤건가요?

당연히  database autoload하였구요.

컨트롤러 create 메소드에서 아래와 같구요

function __construct()
    {
        parent::__construct();        
    }
 
    public function create()
    {
      $this->load->model('hospital_model');
       
       $data = array(
       'did' => $did,
       'lid' => $lid,
       'hcid' => $hcid,
       'h_keyword' => $this->input->post('h_keyword'),
       'h_etc_keyword' => $this->input->post('h_etc_keyword'),
       'h_name' => $this->input->post('h_name'),
       'h_phonenum' => $this->input->post('h_phonenum'),
       'h_homepage' => $this->input->post('h_homepage'),
       'h_zip_code' => $this->input->post('h_zip_code'),
       'h_address1' => $this->input->post('h_address1'),
       'h_details' => $this->input->post('h_details'),
       'h_reserv_status' => $this->input->post('h_reserv_status'),
       'h_qna_status' => $this->input->post('h_qna_status')       
      );     
      
      $this->hospital_model->create();
    }
 hospital_model

class Hospital_model extends CI_Model  {
        
    function __construct()
    {
        parent::__construct();        
    }
 
    public function create()
    {
      if($this->db->insert('hospital', $data)){
          return TRUE;
      };
      return NULL;
    }
}
insert하는데 Call to a member function insert() on a non-object  이런 에러가 나네요.

이거 뭐가 문제인건가요? 아..미치겠네요.


 다음글 aa.com/클래스/index/파라미터 에서 index... (4)
 이전글 cron으로 돌리려니 오류가 나네요;; (4)

댓글

양승현 / 2012/05/04 19:19:38 / 추천 0
데이터베이스 클래스로드가 안되었네요. 오토로드와 설정등을 다시 봐보세요
코드원 / 2012/05/04 19:25:35 / 추천 0
 // $autoload['libraries'] = array('database'); 분명 해줬어요.
한대승(불의회상) / 2012/05/04 19:27:41 / 추천 0
 혹시나 하고 물어 보는건데..

// $autoload['libraries'] = array('database');
에서 // 안지우신건 아니죠.

올려주신 문맥 그대로라면 당연히 에러 납니다.
코드원 / 2012/05/04 19:31:02 / 추천 0
 불의화상님.. 당연히 // 이건 없죠.. ㅎㅎㅎㅎ 
한대승(불의회상) / 2012/05/04 19:47:38 / 추천 0
근데 $data 는 어디서 받나요?
넘겨주는 부분이 없는거 같은데...

현재 발생하고 있는 에러하고는 상관 없는듯 하구요.

$autoload 에 제대로 설정해 주셨다면 발생하지 않을 에러 입니다.

$this->load->database();

가 도움이 될지도
milosz / 2012/05/05 07:47:43 / 추천 0
 불의회장님 말씀대로 database가 로드가 잘 안된 것 같네요. 그리고...
//controller
...
$this->hospital_model->create($data);
...

//model
public function create($data)
{ ...
배강민 / 2012/05/07 09:14:39 / 추천 0
불의회상님은

불의회상, 불의화상, 불상, 불의회장... 참 다양해지시네요..ㅋ