SPrelewicz
Programmer
I am doing an application where I have essentialy a class per table of my mySQL database. I am stuck at a one-to-many and how to implement the classes.
Specifics:
I have a property table (and class), and an apartment table(and class). The apartment table has a foreign key property_id to the property it belongs to. Currently, when I instantiate an apartment, I have a new Property being created as a property attribute. Thus, I can get the properties information by $apartment->property->get_property_name, etc...
Okay, that part seems correct. Now, if I have a property and I want to get all the apartments of that property when I instantiate the property object, I run into proplems. In the constructor I have $property->apartments = new apartmentCollector(). [I use a collector class for lists]. It hanges here, as it seems to get caught when the APARTMENT is instantiating a new Property, but I am instantiating the apartment from Property(). Makes sense?
Does anyone have any advice on how to do this properly?
Thank you,
Scott
This may not seem to PHP, but I am using PHP, and am looking for examples *in* php
Specifics:
I have a property table (and class), and an apartment table(and class). The apartment table has a foreign key property_id to the property it belongs to. Currently, when I instantiate an apartment, I have a new Property being created as a property attribute. Thus, I can get the properties information by $apartment->property->get_property_name, etc...
Okay, that part seems correct. Now, if I have a property and I want to get all the apartments of that property when I instantiate the property object, I run into proplems. In the constructor I have $property->apartments = new apartmentCollector(). [I use a collector class for lists]. It hanges here, as it seems to get caught when the APARTMENT is instantiating a new Property, but I am instantiating the apartment from Property(). Makes sense?
Does anyone have any advice on how to do this properly?
Thank you,
Scott
This may not seem to PHP, but I am using PHP, and am looking for examples *in* php