perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luiz Fernando Bernardes Ribeiro <l...@engenhosolucoes.com.br>
Subject Re: connect to db using an imported .epl file
Date Wed, 09 Apr 2003 12:18:01 GMT
Hi,

The common "Embperl way" for this is to use the request object - $req 
(mod_perl) var tha is passed to every page in @_, example:

Write an epl page that connects to your database and put the $dbh in $req:
[-
$req = shift;
$req->{dbh} = DBI->...
-]

And in all other pages put something like:
[-
Execute('connect.epl');
$req = shift;
$dbh = $req->{dbh};
-]

Don't forget to use Apache::DBI to avoid reconection on every request.

Regards,

Luiz Fernando B. Ribeiro
Engenho Soluções S/C Ltda.


Em Qua 09 Abr 2003 06:30, Alexander Hartmaier escreveu:
> Hi list!
> I wrote this a week ago but got no responses.
> Has someone an idea??? THX!!!
>
> I've got a file called 'nacadminlib.epl' which is imported using
>
> [-
>   use strict;
>   use nactools;
>   Execute ({ inputfile => 'nacadminlib.epl', import => 1 });
> -]
>
> in every of my .epl pages.
>
> Now I want to open my database connection there instead of doing this in
> every .epl seperatly.
>
> I added the following lines to my nacadminlib.epl file:
>
> [-
>   $dbh = connectdbnacweb();
> -]
>
> How can i export this var or/and how can I access it from the .epl pages???
>
> I tried
>
> [!
>   use nactools;
>   use vars qw($dbh);
> !]
>
> but this doesn't work...
>
> THX Alex
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Mime
View raw message