CDBI not blessing my references

[prev] [thread] [next] [Date index for 2004/06/29]

From: Alexander =?iso-8859-1?Q?Gr=E4fe?=
Subject: CDBI not blessing my references
Date: 14:18 on 29 Jun 2004
Hi.

I've been banging my head against this for a while now, but so far I
have not been able to find a working CDBI solution:

I have four tables:
company,knowhow,details and language

The tables (heavily simplified) look like this:

company
-------

id INT()
name VARCHAR()

language
--------

id INT()
name VARCHAR()

knowhow
-------

id INT()
name VARCHAR()
company INT() [references company table]

details
-------

id INT()
language INT() [references language table]
knowhow INT() [references knowhow table]

So every company can have many knowhows, and every knowhow can have many
details (one for every language in the system)

My Foo::Knowhow has these snippets:

----snip----
__PACKAGE__->has_many(details => 'Foo::Details' => "knowhow");

sub details2
{
        my ($self,$lang) = shift;
        my $rv={};
        my @details = $self->details;
        foreach my $detail (@details)
        {
                if($detail->sprache->iso eq $lang)
                {
                        $rv=$detail;
                }
                                                                                                                                                                                      
        }
        return $rv;
}
----snip----

So that I sould be able to get the english details by doing $company->details2("en");

I *do* get something back, but when I try to call isa("Foo::Details") on the return value,
I get a 'Can't call method "isa" on unblessed reference' error.
I get the same error trying to call any Foo::Details method on it.

How can I get CDBI to actually give back a Foo::Details object from Foo::Knowhow?

Regards,
	Alexander Gräfe

CDBI not blessing my references
Alexander =?iso-8859-1?Q?Gr=E4fe?= 14:18 on 29 Jun 2004

Re: CDBI not blessing my references
Tony Bowden 17:31 on 29 Jun 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52