OOP Perl and CGI Methods -- Any Known Problems?

From: Ron Wingfield (rtwingfield_at_archaxis.net)
Date: 12/26/04


To: <dbi-users@perl.org>
Date: Sun, 26 Dec 2004 15:26:18 -0600

I have tried experiments as many of you have suggested, but I just can't get the

  use DBI;
  use CGI;
  $cgi= new CGI;
  eval "require $database";
  etc.

scenario to connect to a database. Oddly, I have been unexpectly succssful with a connection constructed as follows in the function-based (i.e., non-OOP Perl) environment as follows:

  use CGI qw(:standard escapeHTML);
  my $dbh=Cookbook::connect();

This accomplishes a "wholesale" connection without any regard for $localhost, $userid or $passwd. Apparently, the spelling, "Cookbook", is irrelevant, because the name of the database is actually "cookbook" (from Paul DuBois' book, MySQL Cookbook, O'Reilly, 2003.). This actually surprises me because the connection does not specify the $userid, $passwd, or $localhost information.

Now that I have invested a day converting a Perl forms program from functional to OOP methods, the simple connect example does not connect. There must be some little wiggle that I'm just not "getting". It also seems like the "die" constructs do not work, either -- the program execution just seems to blow right past 'em. Are there any known problems with the versions of Perl, MySQL, etc. that I'm using? (see my signature)

Thanks again and OTTF,
Ron Wingfield

FreeBSD 4.8 -- Apache http 2.0.28 -- MySQL client/server 4.1.7
Perl 5.8.5 -- p5-DBD-mysql-2.9004 driver -- p5-DBI-1.46

--------------------------------------------------------------------------------



Relevant Pages

  • Re: Make database handle persist in CGI/DBI application?
    ... Your CGI is called for each request and then terminated. ... There is no way to make the DBI handle persistant. ... You need a permanently running server for a persistant handle. ... I have tried passing the handle in as a ref parameter, using $dbhRef = /*dbh ...
    (perl.dbi.users)
  • Re: niranjani
    ... i have to use for we enabled work using html for that which cgi version ... tp be used and only dbi module is enough or else dbd:odbc also required ... How do I install DBI on Windows for Perl 5.6.1? ...
    (perl.dbi.users)
  • Re: new CGI::Session creates a new session every visit. GRRR!!!
    ... it seems to be something screwy with a combination of DBI and global ... my $cgi = new CGI; ... I want my $cgi and $session variables to be ...
    (comp.lang.perl.misc)
  • RE: How to track the success of insert
    ... > How will I track if the insertion is success or not? ... > use CGI; ... > use DBI; ... Put your instert inside a transaction like this: ...
    (perl.beginners)
  • Re: new CGI::Session creates a new session every visit. GRRR!!!
    ... it seems to be something screwy with a combination of DBI and global ... my $cgi = new CGI; ... I want my $cgi and $session variables to be ...
    (comp.lang.perl.misc)