1

//My controller section

<?php
class Myadmin extends CI_Controller 
{
            public function _construct()    
            {
             parent::_construct();
             $this->load->library('form_validation');
             $this->load->helper('form');
             $this->load->model('adder','',TRUE);
            }

            public function index() 
            {
                    echo " i am about to call the model";
                    $this->adder->insert_user();        
            }
}
?>    
**//My model section**

<?php
class Adder extends CI_Model    {
        function_construct()    {
            parent::_construct();
        }

        public function insert_user()   
        {
              echo " Hi ,the model is accessed";    
        }
}
?>
1
  • 1
    These aren't actually in the same file, are they? Commented Jun 27, 2011 at 14:03

2 Answers 2

2

Is it because of "function_construct()"? It has no space and you should use two _

function _construct(){ parent::_construct(); } Same in Controller

Sign up to request clarification or add additional context in comments.

Comments

1

The problem is the way you load the model in your controller.

In the current version of the CodeIgniter you should do something like this:

//loading the model
$this->load->model('adder', 'fubar');

//accessing it's functions
$this->fubar->function();

for more info see this.

EDIT: You have defined a _construct() function which must be __construct(). Also you should fix parent::_construct(); to parent::__construct().

1 Comment

also your code has a problem in it's constructor as WordsWorth mentioned.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.