The Perl Advent Calendar needs more articles for 2022. Submit your idea today!

Mojolicious::Plugin::DSC - use DBIx::Simple::Class in your application.


  # Mojolicious
  $self->plugin('DSC', $config);

  # Mojolicious::Lite
  plugin 'DSC', $config;

  my $user = $app->dbix->query('
    SELECT * FROM users WHERE user=?','ivan');
  #...and if you added My::User to 'load_classes' (see below)
  my $user = My::User->query(
    'SELECT * FROM users WHERE user=?','ivan');

Mojolicious::Plugin::DSC is a L<Mojolicious> plugin that helps you
use L<DBIx::Simple::Class> in your application.
It also adds a helper (C<$app-E<gt>dbix> by default) which is a DBIx::Simple instance.


You can add all classes from your schema to the configuration 
and they will be loaded so you do not have to C<use My::Table>.
The configuration is pretty flexible:

  # in Mojolicious startup()
  $self->plugin('DSC', {
    dsn => 'dbi:SQLite:database=:memory:;host=localhost'
  $self->plugin('DSC', {
    driver => 'mysqlPP',
    database => 'mydbname',
    host => '',
    user => 'myself',
    password => 'secret',
    onconnect_do => [
      'SET NAMES UTF8',
    dbh_attributes => {AutoCommit=>0},
    namespace => 'My',
    #will load My::User, My::Content, My::Pages
    load_classes =>['User', 'Content', 'My::Pages'],
    #now you can use $app->DBIX instead of $app->dbix
    dbix_helper => 'DBIX' 


Copyright 2012 Красимир Беров (Krasimir Berov).

This program is free software, you can redistribute it and/or modify
it under the terms of the Artistic License version 2.0.

See for more information.