perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexander Hartmaier" <Alexander.Hartma...@t-systems.at>
Subject Re: Re: connect to db using an imported .epl file
Date Mon, 14 Apr 2003 08:40:14 GMT


Hi!

I tried as Luiz wrote but it doesn't work.

nacadminlib.epl:

[-
  $req = shift;
  $req->{dbh} = connectdbnacweb();
-]

page.epl:

[!
use strict;
use nactools;
Execute ({ inputfile => 'nacadminlib.epl', import => 1 });
!]

[-
eval
{
....
  $req = shift;
  $dbh = $req->{dbh};
....
};
perish($@) if $@;

-]

perish is a function which displays an error page.

I get an 'can't use prepare on an undefined variable' error which is the dbi
error message when $dbh isn't defined.

THX 4 help!

Yours sincerly
Alexander Hartmaier

T-Systems

T-Systems Austria
TCS/Network Monitoring & Security Specialist
address: Hofmühlgasse 3-5, 1060 Wien
telephone: +43 (0)57057 - 4320
fax: +43 (0)57057 - 4152
mobile: +43 (0)676 8642 - 4320
mail: alexander.hartmaier@t-systems.com
Internet: http://www.t-systems.at





luiz@engenhosolucoes.com.br (Luiz Fernando Bernardes Ribeiro) am 09.04.2003
14:17:31

An:   Alexander.Hartmaier@t-systems.at (Alexander Hartmaier)
Kopie:     (Blindkopie: Alexander Hartmaier/DEBIS/EDVG/AT)

Thema:    Re: connect to db using an imported .epl file



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