On Thu, 29 Aug 2002 15:31:03 +0200 THC Soft <[EMAIL PROTECTED]> wrote:

> The system I use is Linux 2.4.17, Perl 5.6.1, DBI 1.28.
> 
> I'm working on a web application consisting mainly of a CMS. Now
> consider the following simple test script:
> 
> use Content::Category;
> use DBD::mysql;

That should be 'use DBI;'.  Which DBD you are using is specified in the
connect() call.

> use Data::Dumper;
> 
> my $dbh;
> $dbh = DBI->connect('DBI:mysql:database=baz', 'foo', 'me',
>                      { RaiseError => 1, AutoCommit => 1 }) || die
> $dbh->errstr;

With 'RaissError => 1', connect will not return if it fails, so die() will
never get called.

The 'DBI:' in the first argument to connect() should be 'dbi:'.

> print Dumper($dbh);
> my $cat = Content::Category->new ($dbh, { 'arg1'  => 'something',
>                                           'id'      => 1
>                                         } );
> 
> $dbh->disconnect;
> 
> Content::Category does not query the database itself, but passes the
> handler to its SUPER constructor in Content.pm. The funny thing now is
> that, although Data::Dumper prints out something hopefully valuable
> (VAR1 =  bless ( {}, DBI::db } ), I get (DBI_TRACE = 5) the following
> strange output:

I could not find either Content or Content::Category in CPAN.  Are they DBI
aware?

>     <- connect= DBI::db=HASH(0x83c6a08)
> SV = RV(0x8380498) at 0x83e08b4
>   REFCNT = 1
>   FLAGS = (ROK)
>   RV = 0x83e08c0
>         (in cleanup) dbih_getcom handle DBI::db=HASH(0x83e08c0) is not a DBI
> handle (has no magic) at
> /usr/local/lib/perl5/site_perl/5.6.1/i686-linux/Forum/Content/Node.pm
> line 343.
> SV = RV(0x8380474) at 0xbffff3a0
>   REFCNT = 1
>   FLAGS = (ROK,READONLY)
>   RV = 0x83e08c0
> SV = RV(0x838048c) at 0xbffff250
>   REFCNT = 1
>   FLAGS = (ROK,READONLY)
>   RV = 0x83e08fc
>         (in cleanup) dbih_getcom handle DBI::dr=HASH(0x83e08fc) is not a DBI
> handle (has no magic) at
> /usr/local/lib/perl5/site_perl/5.6.1/i686-linux/Forum/Content/Node.pm
> line 343.
>     -> disconnect for DBD::mysql::db (DBI::db=HASH(0x83c6a08)~0x83c69c0)
> &imp_dbh->mysql: 83177cc
>     <- disconnect= 1 at sbin/test.pl line 29
>     <> DESTROY ignored for outer
> 
> What is going on? Can anyone give me a hint?

It looks like something is overwriting parts of the memory refered to by
$dbh.

Were you getting the same error before you tried dumping $dbh with
Dumper()?
-- 
Mac :})
** I normally forward private questions to the appropriate mail list. **
Ask Smarter: http://www.tuxedo.org/~esr/faqs/smart-questions.html
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.

Reply via email to