Welcome Guest, Not a member yet? Register   Sign In
Unable to locate the model
#1

[eluser]Crabby[/eluser]
Hi Guys

I'm a CodeIgniter newbie and I'm just getting to grips with system at the moment, it looks like a great system. I just have a couple of queries I hoping someone could help me with, firstly I've set up these two files, but when I go to the domain www.mydomain.com/appName/index.php?blog it comes up with this error?

Code:
An Error Was Encountered

Unable to locate the model you have specified: blog

Any ideas what could be wrong?

Code:
//controllers/blog.php
<?php
class Blog extends Controller {

    function __construct()
    {
        parent::Controller();
    }

    function index()
    {
        $this->load->model('Blog');
        $data['categories'] = $this->Blog->get_blog_categories();
        $this->load->view('blog_categories',$data);
    }
    
}

?>

Code:
//models/blog_model.php
<?php

class Blog_model extends Model {

    function __construct()
    {
        parent::Model();
    }
    
    public function get_blog_categories()
    {
        $sql = "SELECT * FROM blog_categories";
        $results = $this->registry['database']->query($sql);
        return $results;    
    }    
    
}

?>

Also can you have friendly urls using IIS?

Any help would be much appreciated

Thanks in advance

Crabby
#2

[eluser]Michael Wales[/eluser]
Code:
$this->load->model('Blog_model');

The parameter is always the class name.
#3

[eluser]Crabby[/eluser]
wow that was a quick reply thank you very much, do have to have _model in your class name?
#4

[eluser]Michael Wales[/eluser]
No you can name it whatever you want (although if you are on PHP4 there are some reserved names, and of course you can't declare the same class name twice).

Me personally, I append _m to my models (user_m, project_m, etc.).




Theme © iAndrew 2016 - Forum software by © MyBB