Question

I am trying the following code but keep getting the this error:

PHP Fatal error: Call to undefined method news_model::get_db_message()

in my application/core/My_Model.php

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

    public function get_db_meesage() {
        echo "bla";
    }
}

this is my news_model.php

class news_model extends MY_Model {
    public function __construct()
    {
        parent::__construct();
    }

    public function delete_news($news_id) {
        $this->get_db_message();
    }
}

I felt it is probably a very subtle error but I just can't figure this out..

Was it helpful?

Solution

Correct answer taken from comments.

Codeigniter expects classes to start with a capital letter. This is stated in their General Style and Syntax document.

To quote:

Class and Method Naming

Class names should always start with an uppercase letter. Multiple words should be separated with an underscore, and not CamelCased. All other class methods should be entirely lowercased and named to clearly indicate their function, preferably including a verb. Try to avoid overly long and verbose names.

INCORRECT: class superclass , class SuperClass

CORRECT: class Super_class

OTHER TIPS

public function get_db_meesage() {
    echo "bla";
}

PHP Fatal error: Call to undefined method news_model::get_db_message()



get_db_message() 

get_db_meesage()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top