Welcome Guest, Not a member yet? Register   Sign In
Nettuts Day 1 - Model Problems
#1

[eluser]domoench[/eluser]
I'm a brand spanking new CodeIgniter user stuck on the Nettuts Day 1 Tutorial where a basic model is used. At 28:29 his works and mine does not. I have the feeling the issue is obvious but I can't see anything that differs from the tutorial.

My default controller is as follows:

site.php
Code:
<?php
class Site extends CI_Controller
{
    function index()
    {
        $this->load->model('site_model');        
        $this->load->view('home');
    }
}
?>

Up until adding the model-loading line everything worked fine. But after that line is added the browser loads a blank page- No error message pointing me to a problem.

My model is as follows:

site_model.php
Code:
<?php
class Site_model extends Model
{
    function getAll() {
        $q = $this->db->get('test'); //gets test table from ci_series database
        
        if($q->num_rows() > 0)
        {
            foreach($q->result() as $row)
            {
                $data[] = $row;
            }
            return $data;
        }
    }
}
?>

Any idea why this isn't working or outputting error messages?

Thanks very much for any advice!
David
#2

[eluser]JonoB[/eluser]
I think that the NetTuts is based on CI 1.7.

For CI 2.0+ you should use:
Code:
class Site_model extends CI_Model
#3

[eluser]domoench[/eluser]
Thanks JonoB. That was indeed the issue.




Theme © iAndrew 2016 - Forum software by © MyBB