You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Alexander Hartmaier <Al...@t-systems.at> on 2003/04/09 11:30:25 UTC

connect to db using an imported .epl file


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


Re: connect to db using an imported .epl file

Posted by Luiz Fernando Bernardes Ribeiro <lu...@engenhosolucoes.com.br>.
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