Welcome Guest, Not a member yet? Register   Sign In
Model Not Loaded?
#1

[eluser]Vik[/eluser]
I've just started working with CI, I have a newbie question.

I have a controller that contains this code:
Code:
<?php
class Alloy_Planner extends Controller {

    function Alloy_Planner()
    {
        echo ('a');
        parent::controller();
        echo ('b');
        $this->load->model('add_alloys_model');
        echo ('c');
    }
    
    function index()
    {
        $data['title']= 'Alloy Planner';
        $this->load->view('alloy_planner_views/add_alloys_view', $data);
            
    
    }
    
    function search()
    {
        $data['title']= 'Alloy Planner';
        $alloy_name = $this->input->post('alloy_name');
        
        $data['search_results'] = $this->add_alloys_model->getSearchResults($alloy_name);
        
        $this->load->view('alloy_planner_views/search', $data);
            
    
    }
}
?>

I have a file called "add_alloys_model.php" (well, it's actually not alloys, it's something else, but I'm not ready to announce it yet) in the models folder. But, it looks like it's not being loaded. The echo statements in the code print out 'a' and 'b', and then everything stops. The rendered html page is completely blank.

What should I check in order to fix this?
#2

[eluser]chobo[/eluser]
try this

Code:
$this->load->model('add_alloys_model', '' ,true);
#3

[eluser]Vik[/eluser]
I tried the suggestion:
Code:
$this->load->model('add_alloys_model', '' ,true);
...but the anomaly is still present.

I'm sure this is some sort of newbie error. Are there any other things I could check?
#4

[eluser]Rick Jolly[/eluser]
If you are on windows this might not help, but model names should be capitalized.
#5

[eluser]Michael Wales[/eluser]
models names are only capitalized within the code:
Code:
class Add_allows_model extends Model {
}

Not when the model is called - that should always be lowercase, as is the filename.
#6

[eluser]Michael Wales[/eluser]
In regards to the question - I'm sure it's a syntax error in your model. Blank pages are almost always PHP errors.
#7

[eluser]fMertins[/eluser]
[quote author="walesmd" date="1186695237"]models names are only capitalized within the code:
Code:
class Add_allows_model extends Model {
}

Not when the model is called - that should always be lowercase, as is the filename.[/quote]

Hi! My app is working fine at localhost & Windows, but when trying to do the same in real hosting website using Linux, I got this error:

An Error Was Encountered
Unable to locate the model you have specified: clientemodel

Please take a look this sshot, I stroked the important parts... I´m don´t understanding the problem... Even if I try call model with CamelCase sintax, doesn´t works... :-(

And I´m a little bit ashmed with this "complex" problem... :-P :red:
Thanks again
#8

[eluser]fMertins[/eluser]
*** Understood ***




Theme © iAndrew 2016 - Forum software by © MyBB