XF 2.0 How to get Entities based on IDs in another table

Hello!

I have a table, let's say Table 1, where I have lists of ResourceItem IDs and some additional info associated with them. In my code, I want to fetch those ResourceItems, whose IDs are listed in Table 1 and return them with the extra data associated with them. In SQL, that is very simple by doing an INNER JOIN. But how do I do that using the Finder and Entity system? I tried to add a Relation to Table 1 entity structure and using the "with" finder command, but it placed all data under the relation entry and not to the main level of the entity. How can I return ResourceItem entities with the additional info attached to them?

Best regards,
Tommi
 
The way you did it with the relation and the finder is the correct way.

You would just reference it as {$yourItem.YourRelationName.TheResourceField} in a template or $yourItem->YourRelationName->TheResourceField in PHP code.

$yourItem->YourRelationName will be empty if there's no relation found.
 
Back
Top Bottom