Apache2-WebApp-Plugin-DBI

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
    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

129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
=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

1
2
3
4
5
6
7
8
9
10
# 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

1
2
3
4
5
6
7
[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.263 second using v1.01-cache-2.11-cpan-26ccb49234f )