0
votes

I'm getting an "unable to locate model" error when trying to load a model into the controller. I have the model file in the correct location application/models/welcome_model.php and the controller accessing it is in application/controllers/Welcome.php but it still says it can't locate it.

The code in welcome_model.php:

<?php


class Welcome_model extends CI_Model {
    public function first_query() {
        $query = $this->db->query('SELECT * FROM user');
        return $query->result();
    }
    public function retrieve_user_info(){
    }
    public function retrieve_images() {

    }
}

And I'm calling it in Welcome.php in a function:

    public function index()
    {
        $this->load->database();
        $this->load->model('welcome_model');

        $this->load->view('welcome_message');
    }

This was the error I got:

An uncaught Exception was encountered Type: RuntimeException

Message: Unable to locate the model you have specified: Welcome_model

Filename: /opt/lampp/htdocs/system/core/Loader.php

Line Number: 348

Backtrace:

File: /opt/lampp/htdocs/application/controllers/Welcome.php Line: 24 Function: model

File: /opt/lampp/htdocs/index.php Line: 315 Function: require_once

1

1 Answers

0
votes

Your Model's filename needs to have the 1st letter uppercase.

So instead of

welcome_model.php

it should be

Welcome_model.php