Reputation: 1260
I have two models: models/Categories.php
and models/backend/BE_categories.php
I want BE_categories class to extend Categories, since it has some useful functions I can re-use:
Categories.php
class Categories extends CI_Model
{
...
BE_categories.php
class Be_categories extends Categories
{
...
But when $this->load->model('models/be_categories')
I get the error: Unable to locate the specified class: Session.php yet it works with exending CI_Model
What have I done wrong?
Upvotes: 1
Views: 692
Reputation: 1260
I also had a Controller called Categories.php, with class Categories
, which is where CI was getting confused.
I had to rename models/Categories.php
to models/Categories_model.php
as well as the class name.
But also had to include the file when extending:
BE_categories_model.php
include('application/models/Categories_model.php');
class Be_categories_model extends Categories_model
{
...
Edit:
Thanks to commenter, might be better to to include this model in config/autoload.php instead of using PHP's include()
function.
Upvotes: 1
Reputation: 3710
Just my guess, you load Session library inside some function in Categories model,and then try to use function with session library specific function inside model BE_Categories.
Add Session library in config/autoload.php or load it inside Categories model constructor, and remember to add constructor inside BE_Categories.
Upvotes: 1