A
Alexandre Jaquet
I'm a bit confused where I should place persistant connection and I want
my scripts useds as compiled registry scripts.
I've added in my httpd.conf
PerlModule Apache:B;
<Location /perl-status>
SetHandler perl-script
PerlResponseHandler Apache::Status
</Location>
<Location /script>
SetHandler perl-script
PerlHandler ModPerl::Registry
Options ExecCGI
PerlSendHeader On
Order allow,deny
Allow from all
</Location>
I add on my startup.pl script :
use strict;
use ModPerl::Registry ();
use Apache2 ();
use Apache:BI;
use Image::Magick;
use DBI;
use Mail::Sender;
use Digest::MD5 qw(md5_hex);
use Data:umper;
use POSIX;
use CGI ();
CGI->compile(':all');
Apache:BI->connect_on_init
("DBI:mysql:test:localhost",
"username",
"passwd",
{
PrintError => 1, # warn() on errors
RaiseError => 0, # don't die on error
AutoCommit => 1, # commit executes immediately
}
);
return 1;
but now how can I use it in my scripts who needs to use this connection
? for exemple I consider $dbh as the connection reference
$dbh->do($sql) ...
my scripts useds as compiled registry scripts.
I've added in my httpd.conf
PerlModule Apache:B;
<Location /perl-status>
SetHandler perl-script
PerlResponseHandler Apache::Status
</Location>
<Location /script>
SetHandler perl-script
PerlHandler ModPerl::Registry
Options ExecCGI
PerlSendHeader On
Order allow,deny
Allow from all
</Location>
I add on my startup.pl script :
use strict;
use ModPerl::Registry ();
use Apache2 ();
use Apache:BI;
use Image::Magick;
use DBI;
use Mail::Sender;
use Digest::MD5 qw(md5_hex);
use Data:umper;
use POSIX;
use CGI ();
CGI->compile(':all');
Apache:BI->connect_on_init
("DBI:mysql:test:localhost",
"username",
"passwd",
{
PrintError => 1, # warn() on errors
RaiseError => 0, # don't die on error
AutoCommit => 1, # commit executes immediately
}
);
return 1;
but now how can I use it in my scripts who needs to use this connection
? for exemple I consider $dbh as the connection reference
$dbh->do($sql) ...