开发者

PHP Codeigniter Class model not found

I am trying to connect mssql and codeigniter and the result is:

Fatal error: Class 'Pekerja_model' not found in C:\xampp\htdocs\CodeIgniter\system\core\Loader.php on line 188

This my code

Model

class Pekerja_model extends CI_Model {  
    function SomeMSSQLModel() {
        $this->_db = $this->load->database('mssql-group', TRUE);    
    }   

 开发者_StackOverflow社区   function pekerja_model(){       
        parent::__construct(); 
    }    

    function pekerja_lihat(){
        $this->load->database('mssql-group', TRUE);         
        $query=get('');
        return $query->result();     
    } 
}

View

foreach($query as $row)
    echo $row['nama'];

Controller

class pegawai extends CI_Controller{

    function __construct(){
        parent::__construct();
    }

    function getall(){
        $this->load->model('Pekerja_model');
        $data['query']=$this->load->Pekerja_model->pekerja_lihat();
        $this->load>view('getall',$data);   
    }   
}

thank you


in CI your class name should start by Capital but call with small. and another thing I think is

$this->load->Pekerja_model->pekerja_lihat();
is wrong,you should use
$this->pekerja_model->pekerja_lihat(); 


Firstly your file name must be pekerja_model(i.e. small p) & following is your updated controller class pegawai extends CI_Controller{

function __construct(){
    parent::__construct();
}

function getall(){
    $this->load->model('pekerja_model');
    $data['query']=$this->pekerja_model->pekerja_lihat();
    $this->load>view('getall',$data);   
}   

}

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜