Welcome Guest, Not a member yet? Register   Sign In
Trouble loading model
#1

[eluser]nathj07[/eluser]
Hi,

I'm new to the CI framework but so far so good.

I'm currently working on a simple proof of cncept thing to write some form information to a database. With a background in Java I am keen to keep to the MVC way of doing things and so I have created a MY_Controller and a MY_Model. Both of these extend their CI_ counterparts and exist in application/core directory. The MY_Controller class seems just fine.

So all my controller classes extend MY_Controller and this works just fine. I have sketched the early beginnings of a model class within the application/models directory and am attempting to load this in a controller. However, the load line causes a 500 Internal Server error.

Here is the code for the 2 custom model classes:

MY_Model
Code:
<?php (defined('BASEPATH')) OR exit('No direct script access allowed');



class MY_Model extends CI_Model

{

    

    public function __construct()

    {

            parent::__construct();

            $this->load->helper('url');

            $this->load->helper('form');

            $this->load->helper('typography');

            $this->load->library('form_validation');            
            
            $this->load->dbutil();

    }

}
/* End of file MY_Model.php */

/* Location: ./application/core/my_model.php */

/* Last edit: Nathan - initial Creation 04/03/2011 */

The news_model class (snippet):

Code:
<?php

class News_model extends MY_Model

{
    private $_news_data;
    
     function __construct()
    {
           parent::__construct();

            $this->load->helper('url');

            $this->load->helper('form');

            $this->load->helper('typography');

            $this->load->library('form_validation');            
            
            $this->load->dbutil();
    }
    
    // functions for creation
In the news.php class I have (snippet):
Code:
class News extends MY_Controller

{

    

    function __construct()

    {

        parent::__construct();        
    }

    

    function index()

    {

        $this->load->model('News_model');        
        $this->load->view('writeNews_view');
    }
    
    // functions for creation    
    function collect_news_data()
    {
        $this->load->view('writeNews_view');
    }
    
    function write_news_data()
    {
It doesn't matter where I put the model load line - index() or collect_news_data() and I still get the error.

This is really annoying me now as I cannot figure out how to do it. Any help on this would be greatly appreciated.

Many thanks
Nathan


Messages In This Thread
Trouble loading model - by El Forum - 03-29-2011, 07:11 AM
Trouble loading model - by El Forum - 03-29-2011, 08:04 AM
Trouble loading model - by El Forum - 03-29-2011, 08:38 AM
Trouble loading model - by El Forum - 03-29-2011, 08:49 AM
Trouble loading model - by El Forum - 03-29-2011, 09:18 AM
Trouble loading model - by El Forum - 04-06-2011, 06:10 PM
Trouble loading model - by El Forum - 04-07-2011, 02:17 AM



Theme © iAndrew 2016 - Forum software by © MyBB