Reputation: 13
The Error:
Fatal error: Swiftlet\App::autoload(): Failed opening required 'Swiftlet/Models/mysqli.php' (include_path='.:/usr/local/lib/php-5.3.13/lib/php') in /hermes/waloraweb009/b1166/htdocs/jim/ss test/Swiftlet/App.php on line 223
I'm new to MVC and trying out Swiftlet. I'm trying to setup a MYSQL database Model.
I've nailed down the error to:
class Database extends \Swiftlet\Model {
public $mysqli;
public function __construct(App $app) {
$this->mysqli = new mysqli($this->app->getConfig('dbHost'),
$this->app->getConfig('dbUser'),
$this->app->getConfig('dbPassword'),
$this->app->getConfig('dbName'));
}
}
But I don't know why. Why would it try to load mysqli
?
Upvotes: 1
Views: 247
Reputation: 71384
It seems the problem is that you are likely in \Swiftlet
namespace. When trying to instantiate mysqli (an item in global namespace) from within this name space, it is trying to autoload where it would normally look to autoload classes within it's namespace. The class isn't there, thus you get the autoload error.
Try changing your mysqli instantiation like this:
$this->mysqli = new \mysqli($this->app->getConfig('dbHost'), $this->app->getConfig('dbUser'), $this->app->getConfig('dbPassword'), $this->app->getConfig('dbName'));
Note that myslqi
is now prefixed by \
thus referencing the mysql class in the global namespace.
Upvotes: 1