grantus
Active member
I followed the XF docs about relations but it doesn't seem to work for me.
I have a table
I have this in my entity:
Because I want to match up
This is my query setup:
I was using
I did a dump on the query and it looks correct. What could be giving this error?
I have a table
battle_points
that contains user_id
column.I have this in my entity:
Code:
$structure->relations = [
'User' => [
'entity' => 'XF:User',
'type' => self::TO_ONE,
'conditions' => 'user_id',
'primary' => true
],
];
$structure->defaultWith = ['User'];
Because I want to match up
user_id
from both the battle_points and xf_user tables.This is my query setup:
Code:
$archives = $this->finder('Test\ILL:BattlePoints')
->where('winner', 'yes')
->where('user_id', '>', 0)
->order('battle_date', 'DESC');
$forum_username = $archives->User->username;
$page = $params->page;
$perPage = 20;
$archives->limitByPage($page, $perPage);
$viewParams = [
'archives' => $archives->fetch(),
'page' => $page,
'perPage' => $perPage,
'total' => $archives->total(),
'forum_username' => $forum_username
];
I was using
$archives.username
in my template which works fine, but to test I did $archives.forum_username
and I get the error message:
Code:
LogicException: Unknown relation username accessed on xf_user in src/XF/Mvc/Entity/Finder.php at line 100
I did a dump on the query and it looks correct. What could be giving this error?