XF 2.2 Clarification on entity relations

Dannymh

Active member
HI all,

I wanted to get some clarification on the entity relations. The documentation references the field in the conditions but doesn't tell me precisely if that is the foreign field or the local table field.
Furthermore, what happens if the field i want to join based on is named something different in the foreign table.

In my case I am joining my table onto the post table and want to join based on on the mytable.localpost = post ID from the post table. Would the following work, or how would I pass the current post_id into that

PHP:
$structure->relations = [
            'myTable' => [
                'entity' => 'XF:MyEntity',
                'type' => self::TO_ONE,
                'conditions' => [
                    ['localpost', '=', '$post_id']
                ],
                'primary' => true
            ]
 
Top Bottom