Apache2-WebApp-Plugin-DBI

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN


CONFIGURATION
    Unless it already exists, add the following to your projects
    *webapp.conf*

      [database]
      driver      = mysql
      host        = localhost
      name        = database
      user        = foo
      password    = bar
      auto_commit = 0

OBJECT METHODS
  connect
    Make a new database connection.

      my $dbh = $c->plugin('DBH')->connect({
          driver    => 'mysql',
          host      => 'localhost',
          name      => 'database',
          user      => 'bar',
          password  => 'baz',
          commit    => 1 || 0,
        });

      my $sth = $dbh->prepare("SELECT * FR..");

SEE ALSO
    Apache2::WebApp, Apache2::WebApp::Plugin, Apache::DBI, DBI

AUTHOR
    Marc S. Brooks, <mbrooks@cpan.org> - <http://mbrooks.info>

lib/Apache2/WebApp/Plugin/DBI.pm  view on Meta::CPAN

    my ( $self, $config )
      = validate_pos( @_,
          { type => OBJECT  },
          { type => HASHREF }
          );

    my $driver   = $config->{driver};
    my $host     = $config->{host}    || 'localhost';
    my $name     = $config->{name};
    my $user     = $config->{user};
    my $password = $config->{password};
    my $commit   = $config->{commit};

    return if (!$name && !$user && !$password);

    return DBI->connect(
        "dbi:$driver:$name:$host", $user, $password,
          {
              PrintError => 1,
              RaiseError => 1,
              AutoCommit => ($commit) ? 1 : 0,
          }
      )
      or $self->error($DBI::errstr);
}

#~~~~~~~~~~~~~~~~~~~~~~~~~~[  PRIVATE METHODS  ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

lib/Apache2/WebApp/Plugin/DBI.pm  view on Meta::CPAN


=head1 CONFIGURATION

Unless it already exists, add the following to your projects I<webapp.conf>

  [database]
  driver      = mysql
  host        = localhost
  name        = database
  user        = foo
  password    = bar
  auto_commit = 0

=head1 OBJECT METHODS

=head2 connect

Make a new database connection.

  my $dbh = $c->plugin('DBH')->connect({
      driver    => 'mysql',
      host      => 'localhost',
      name      => 'database',
      user      => 'bar',
      password  => 'baz',
      commit    => 1 || 0,
    });

  my $sth = $dbh->prepare("SELECT * FR..");

=head1 SEE ALSO

L<Apache2::WebApp>, L<Apache2::WebApp::Plugin>, L<Apache::DBI>, L<DBI>

=head1 AUTHOR

usr/share/webapp-toolkit/plugin/base/DBI.tt  view on Meta::CPAN

    # stash the database object for later use
    my $dbh = $c->plugin('DBI')->connect({
        driver   => $c->config->{database_driver},
        host     => $c->config->{database_host},
        name     => $c->config->{database_name},
        user     => $c->config->{database_user},
        password => $c->config->{database_password},
      });
    
    $c->stash('DBH', $dbh);

usr/share/webapp-toolkit/plugin/conf/DBI.tt  view on Meta::CPAN

[database]
#driver             = [% database_driver || 'mysql'     %]
#host               = [% database_host   || 'localhost' %]
#name               = [% database_name %]
#user               = [% database_user %]
#password           = [% database_password %]
#auto_commit        = [% database_auto_commit || 1 %]



( run in 0.285 second using v1.01-cache-2.11-cpan-26ccb49234f )