I've just generated your schema in my own Propel environment, and found that you should currently have this:
/* @var $user User */
$user = new User();
$user->getUserRelatedByParentUserId();
$user->getUserClass();
I notice that you have phpName
attributes on various columns - I'd recommend removing them, since you're requesting the defaults that would be generated anyway.
However, you're on the right track - try this:
<foreign-key foreignTable="user" name="fk_user_parent" phpName="ParentUser">
<reference local="parent_user_id" foreign="id"/>
</foreign-key>
I'm assuming you're happy with the default relation name given to UserClass, so that doesn't change. However, for the self-join, I've added a custom relation name, which should give you $user->getParentUser()
.
Incidentally, I expect you're using the name
attributes on the FK definitions to give custom names to your constraints. That's fine if you want control over this, but I tend to let Propel name them as it wishes. If you are happy with that, they can be removed from the schema.