[eluser]toadies[/eluser]
Hello, I have been lurking on here for awhile and tried to read as much as I can. But I'm not familiar with Datamapper ORM.
I believe i'm trying to use Has-Many Relationships and wondering if someone could help me setup my relationships...
Here are my tables
customers:
id
first_name
last_name
equipment_groups:
id
name
equipments:
id
equipment_group_id
name
manufacturers:
id
equipment_id
name
So I assume I would create a 5th table called customers_equipments with the following fields
id
equipment_id
customer_id
manufacturer_id
model_name
In my model I put
Customer Class - var $has_many = array('equipment');
Equipment Class - var $has_many = array('customer');
I'm not worried about getting manufacture name or group name yet...
In the controller I would try to access my 1 entry in customers_equipments table, but I would get an entire list of all equipment names from equipment table, not what 1 entry in my table.
$e = new Equipment();
$e->get();
foreach($e as $equip){
echo $equip->name
echo $equip->manufacturer_id;
}
Please help!
Thanks,
Chris