Using the following within the module.php
$di->setShared('db', function() use ($config){
return new DbAdapter(array(
"host" => $config->database->host,
"username" => $config->database->username,
"password" => $config->database->password,
"dbname" => $config->database->dbname,
));
});
Within my controller I can use the following and I can see it gets the 'db' service:
$db = $this->getDI()->get('db');
and it returns the correct object. However when I try to access a model it returns an exception:
Service 'db' was not found in the dependency injection container