CI 묻고 답하기

제목 Model 호출 관련 질문입니다..^^
글쓴이 최강깜시 작성시각 2012/11/27 16:45:22
댓글 : 8 추천 : 0 스크랩 : 0 조회수 : 24225   RSS

이제 막 CI를 사용하고자 하는... 왕초보 입니다..

그런데 테스트로 간단한 게시판을 만들어 볼라구 하다 보니까...

이상하게 Model이 호출이 안되네요..ㅡㅡ;;

소스는... 아래와 같습니다.

application/models/simpleBbsModel.php

class SimpleBbsModel extends CI_Model {
    function __construct() {
        parent::__construct();
    }

    function countAll() {
        return $this->db->count_all_result("sb_board");
    }
}


application/controllers/simpleBbs.php

class SimpleBbs extends CI_Controller {
    function __construct() {
        parent::__construct();

        $this->load->helper(array('form', 'url'));
        $this->load->model("simpleBbsModel");
    }

    function index() {
        $data["total_rows"] = $this->simpleBbsModel->countAll();
        $this->load->view("simpleBbs/list", $data);
   }
}


위의 소스를 실행하면  

An Error Was Encountered
Unable to locate the model you have specified: simplebbsmodel


이런 오류가 발생합니다..ㅜㅜ

왜 그럴까요.. 답변 부탁드립니다...

먼저 감사합니다...^ ^
태그 Model
 다음글 개편 작업시 codeigniter 사용에 대한 질문 (7)
 이전글 [초보]에러메시지 출력 (8)

댓글

템포 / 2012/11/27 17:35:42 / 추천 0

$this
->simpleeBbsModel->countAll();

simplee -> simple

모델명이나 컨트롤러명이나 이런 부분은 저는 첫글자만 대문자쓰는데
관계가 있을지는 잘 모르겠네요 ㅎ


최강깜시 / 2012/11/27 17:36:40 / 추천 0
그 부분을 수정했습니다..^ ^
그건 여기 올리면서 오타 났네요..ㅜㅜ
criuce / 2012/11/27 17:49:37 / 추천 0
Model 명을 저렇게 적으시면 아마 로드가 안될거에요.

첫글자면 대문자였나? 규칙이 그럴겁니다. 
최강깜시 / 2012/11/27 17:50:47 / 추천 0
클래스명이 첫글자는 대문자가 맞는걸로 알고 있습니다.

그런데 파일명은 소문자도 상관없는 걸로 알고 있습니다..ㅡㅜ

그렇게 해봤는데도 안되서...

답변 주셔서 감사합니다..^^
삽질의추억 / 2012/11/27 17:53:08 / 추천 0
class Comments extends MY_Controller

class Comment_model extends CI_Model

파일명은 class 이름이랑 같아야 하는건가 ... ㅋ
템포 / 2012/11/27 17:56:14 / 추천 0
controller 파일명, model 파일명 전부 소문자로 바꾸고
class Simplebbs extends CI_Controller
class Simplebbsmodel extends CI_Model

이렇게 하시고 한번 해보세요.
criuce / 2012/11/27 17:58:09 / 추천 0
코어 Loader 보니까 아래의 코드가 있습니다.

$model = strtolower($model);
$model = ucfirst($model);
$CI->$name = new $model();

이 코드대로라면 첫글자만 대문자여만 로드가 잘 될것 같네요.
최강깜시 / 2012/11/27 18:32:54 / 추천 1
//템포님
감사합니다..ㅡㅡ;;
파일명을 모두 소문자로 바꾸니까 되네요..ㅡㅡ;;;
이런... 어이 없는..ㅋ
정말 감사합니다..^^

//criuce님
해결에 도움주심에 정말
감사합니다...^ ^