Apache2-WebApp-Plugin-DBI
view release on metacpan or search on metacpan
484950515253545556575859606162636465666768697071727374757677787980CONFIGURATION
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
lib/Apache2/WebApp/Plugin/DBI.pm view on Meta::CPAN
363738394041424344454647484950515253545556575859606162
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
129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163=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
12345678910# 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
1234567[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 )