From c8b21742927c217770e950005741850f17b5d32c Mon Sep 17 00:00:00 2001
From: Derek Allard
If you 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');
+$this->load->model('blog/queries');
Once loaded, you will access your model functions using an object with the same name as your class:
diff --git a/user_guide/libraries/loader.html b/user_guide/libraries/loader.html index c9b0bfee4..8cf5478e8 100644 --- a/user_guide/libraries/loader.html +++ b/user_guide/libraries/loader.html @@ -103,8 +103,16 @@ to your browser. Remember to assign it to a variable if you want the data retur$string = $this->load->view('myfile', '', true);
+$this->load->model('Model_name');
If you 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');
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();
This function lets you load the database class. The two parameters are optional. Please see the database section for more info.
-- cgit v1.2.3-24-g4f1b