[eluser]Unknown[/eluser]
I have 2 tables 'plants' and 'categories' with a many-to-many relationship, and using a linking table 'categories_plants' have populated the linking table successfully using datamapper
however, I am stumped when trying to extract data from the plants table by category ('slug' - in this case hard coded as 'Climbers')as all I can get is the id of the plant but no other fields.
using :
function search($value='Climbers'){
$c = new Category();
$c->where('slug',$value)->get();
$p = $c->plant->get();
foreach ($p as $plant){
echo "$plant->id <br/>";
}
}
..I get a listing of the correct ids for plants in category 'Climbers'.
However, I cannot access any other fields from the Plant data eg. $plant->name etc.
Is it possible? I thought $p would be a collection containing all the data related to the individual plants (from the 'plants' table), but it appears to be only the the data held in the linking table. I would appreciate any input that could shed some light on this.