Re: What is the right way to handle a hierarchy of same-class objects?

[prev] [thread] [next] [Date index for 2005/02/22]

From: Karjala
Subject: Re: What is the right way to handle a hierarchy of same-class objects?
Date: 02:25 on 22 Feb 2005
However it would be nice to get undef as an answer.

I have the following scenario on my sites:

Class A objects get created and deleted all the time.

Class B objects (a history log) have a field that refers to a class A 
object (which may or may not exist at the present time). Class B objects 
never get deleted.

I need to check with a short piece of code if given a B object, the 
corresponding A object exists, in order to display a link on the website 
if it does exist.

$b->a would be enough, if it would return null instead of an object 
reference.

Hm...

Sorry for bothering again...




William Ross wrote:

>
> On 21 Feb 2005, at 13:12, Karjala wrote:
>
>> I have a class called (MyTest::)Category.
>>
>> The table of Category has a field ("father") containing the id of the 
>> father category of each category.
>>
>> Objects that don't have a father, have 0 in that field.
>
>
> Make that NULL instead of 0, and everything should work as you expect.
>
> best
>
> will
>
> ps. there is a bug to look out for if you are doing this kind of thing 
> and also have some class-data declarations (eg columns, relationships, 
> temp columns) in both your base class and your data classes. Otherwise 
> it's completely straightforward.
>
>


Re: What is the right way to handle a hierarchy of same-class objects?
Karjala 02:25 on 22 Feb 2005

Generated at 12:48 on 22 Feb 2005 by mariachi v0.52