Welcome Guest, Not a member yet? Register   Sign In
Problem with the Model inclusion
#11

[eluser]BrianDHall[/eluser]
http://ellislab.com/codeigniter/user-gui...odels.html

Quote:Connecting to your Database

When a model is loaded it does NOT connect automatically to your database. The following options for connecting are available to you:

You can connect using the standard database methods described here, either from within your Controller class or your Model class.
You can tell the model loading function to auto-connect by passing TRUE (boolean) via the third parameter, and connectivity settings, as defined in your database config file will be used:
$this->load->model('Model_name', '', TRUE);

So this assumes you aren't auto-connecting to the database using an autoload.

Quote:Loading a Model

Your models will typically be loaded and called from within your controller functions. To load a model you will use the following function:

$this->load->model('Model_name');
If your model is located in a sub-folder, include the relative path from your models folder. For example, if you have a model located at application/models/blog/queries.php you'll load it using:

$this->load->model('blog/queries');
Once loaded, you will access your model functions using an object with the same name as your class:

$this->load->model('Model_name');

$this->Model_name->function();
If you would like your model assigned to a different object name you can specify it via the second parameter of the loading function:

$this->load->model('Model_name', 'fubar');

$this->fubar->function();
Here is an example of a controller, that loads a model, then serves a view:

class Blog_controller extends Controller {

function blog()
{
$this->load->model('Blog');

$data['query'] = $this->Blog->get_last_ten_entries();

$this->load->view('blog', $data);
}
}
#12

[eluser]Helmasaur[/eluser]
[quote author="Eric Cope" date="1261953580"]It sounds like an web server issue. Check the file extensions. Are they any typos?[/quote]
I don't understand about "typos". Can you explain please ?

About the loading of the model with the auto-connection, I modified it, it's now:
Code:
function index()
{
  $this->load->model('News', 'news');        
        
  // $data['last_news'] = $this->news->get_last_news(2);
  // $this->parser->parse('index_view', $data);
}
But it doesn't change anything. There is the same problem Confused.

It doesn't come from the parser function, it's sure.
#13

[eluser]jedd[/eluser]
[quote author="Helmasaur" date="1261949727"]
In the guide, there is no capital letter:
[/quote]

From [url="http://ellislab.com/codeigniter/user-guide/general/models.html"]http://ellislab.com/codeigniter/user-guide/general/models.html[/url]:
Quote:Where Model_name is the name of your class. Class names must have the first letter capitalized with the rest of the name lowercase.

What guide are you reading?
#14

[eluser]Eric Cope[/eluser]
[quote author="Helmasaur" date="1261970975"][quote author="Eric Cope" date="1261953580"]It sounds like an web server issue. Check the file extensions. Are they any typos?[/quote]
I don't understand about "typos". Can you explain please ?

About the loading of the model with the auto-connection, I modified it, it's now:
Code:
function index()
{
  $this->load->model('News', 'news');        
        
  // $data['last_news'] = $this->news->get_last_news(2);
  // $this->parser->parse('index_view', $data);
}
But it doesn't change anything. There is the same problem Confused.

It doesn't come from the parser function, it's sure.[/quote]

instead of .php, its .phg
Apache will only send specific files to the PHP Interpreter. Its a long shot, but worth looking.
#15

[eluser]Helmasaur[/eluser]
I use the officiel guide. I didn't realise about that but capital or no, it stays the same.

Normally, it loads .php fils because if I don't use the model's loader function, all works well.
I can load a model with only the constructor fucntion, it doesn't work.
Can it come from the database auto-connexion ?
#16

[eluser]Helmasaur[/eluser]
Any one knows what is the problem ?




Theme © iAndrew 2016 - Forum software by © MyBB