Forgive me if I’m wrong but I ran into a probably rather simply and stupid error but here’s how you get to it too:
1) Take a clean CI 2.1.0 and copy it to some folder on your server
2) Test in browser => Everything works fine
3) Take a clean Clone from your HMVC (actually it’s from saturday, so your commit form yesterday is not included) and copy it according to the setup rules to the CI-folder
4) Go to browser => Everything works fine
5) Edit ./application/config/database.php and fill in database-information
6) Edit ./application/config/autoload.php and set $autoload[‘libraries’] = array(‘database’);
7) Check page => Works fine
8) Edit ./application/config/database.php and set session’s encryption key as well as ‘use_database’ to TRUE
9) Edit ./application/config/autoload.php and set $autoload[‘libraries’] = array(‘session’);
10) Go to browser => Everything fine
11) Edit ./application/controllers/welcome.php and add
public function __construct()
{
parent::__construct();
}
12) Go to browser => Everything fine
13) Create a MY_Controller in ./application/core with the following code
<?php (defined('BASEPATH')) OR exit('No direct script access allowed');
/* load the MX_Router class */
require APPPATH."third_party/MX/Controller.php"; // comment this line and everything works fine, too
class MY_Controller extends CI_Controller {
function __construct()
{
parent::__construct();
}
}
14) Go to browser and get
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Welcome::$db
Filename: libraries/Session.php
Line Number: 201
Fatal error: Call to a member function where() on a non-object in /var/www/htdocs/codeigniter/ci-hmvc/codeigniter/libraries/Session.php on line 201
First I had that problem within a repo which had per-environment files for both config.php and database.php but not for autoload.php. So I thought the problem was there. But as you can see, it’s coming even with a clean CI-install.
Maybe I got something wrong, but what’s so bad about having your welcome controller extend the CI_Controller and only place a MY_Controller file inside the core-folder which does nothing (except including the MX_Controller) but extending the CI_Controller?
And even if you changed
class MY_Controller extends CI_Controller {
function __construct()
{
parent::__construct();
}
}
to
class MY_Controller extends MX_Controller {
function __construct()
{
parent::__construct();
}
}
you still get that error.
Is this error-creation my fault?
I know why one should use to extend the MX_Controller (for HMVC-stuff) but for this project I thought of seperating HMVC-Controllers from basic-controllers. So to say to have a MY_Controller (extending CI_Controller) for the default-controllers and a HMVC-Controller extending (MX_Controller).
And from my point of view there’s nothing wrong about having a controller extending CI_Controller even if there is a MY_Controller, or is it? Does this interfere with the possibility to extend the core-classes?
Checked with a CI-2.1.0-dev build: Same procedure, but no problems.