Hi,

I have a php page from which I want to connect to database through perl
scripts.
(Or is there any way by which I can call perl functions from php?)
I use DBD::Oracle and DBI for connecting to Oracle from Perl.
When I tried, the connection established through the first script is
found to be invalid
for second script which does some queries to the database,
based on the connectivity obtained in the first script.
Is it possible to make a connection through one script and
use another scripts (not functions) to do queries.
(The whole idea I want here is to use these scripts from php which can
call perl scripts. I wanted to use perl for connecting to database 
as I already have the functions to do database interactions and I want
to reuse it if possible)

I am enclosing a sample perl (instead of php) code which I tried.

try.pl
----
$arr = `./third.pl`;
print $arr; -- printed DBI::db=HASH(0x23e7a4) as returned from third.pl
$ENV{'DBH'} = $arr;
$array = `./fourth.pl`;
print $array;

third.pl
-----
use Database;

$dbh = Database::connect_db(user,passwd,sid,hostname);
print $dbh;

fourth.pl
-----
use Database;

$dbh = $ENV{'DBH'};
print $dbh; -- printed DBI::db=HASH(0x23e7a4)
@res = Database::query_db($dbh,"select * from address");
print @res;  -- gave an error **** Can't locate object method "prepare"
via package "DBI::db=HASH(0x23e7a4)" (perhaps you forgot to load
"DBI::db=HASH(0x23e7a4)"?)

Thanks,
Bineesh

Reply via email to