Skip to content

Instantly share code, notes, and snippets.

@ianmacl
Created October 30, 2013 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ianmacl/7232311 to your computer and use it in GitHub Desktop.
Save ianmacl/7232311 to your computer and use it in GitHub Desktop.
public function register(JoomlaContainer $container)
{
$container->set(
'Joomla\\Database\\DatabaseDriver',
function () use ($container)
{
$app = $container->get('app');
$options = array(
'driver' => $app->get('database.driver'),
'host' => $app->get('database.host'),
'user' => $app->get('database.user'),
'password' => $app->get('database.password'),
'database' => $app->get('database.name'),
'prefix' => $app->get('database.prefix')
);
$db = DatabaseDriver::getInstance($options);
$db->setDebug($app->get('debug.database', false));
return $db;
},
true,
true
);
// Alias the database
$container->alias('db', 'Joomla\\Database\\DatabaseDriver');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment