Skip to content

Accessing hasMany() without foreign key #289

Description

@mmethner

Hello, I know the way how to use hasMany() if there is a database relation like

table articles \Entity\Articles
articles.id = 1
articles.text = ...

table comments \Entity\Comments
comments.id= 2
comments.article_id = 1
comments.text = ...

Accessing it, would look like this.

$mapper->hasMany(
            $entity,
                '\Entity\Comments',
                'article_id'
            ),

What I want to do is, accessing the related table through a member of the original table (not through a mapping table with HasManyThrough()). So the layout looks like this:

table articles \Entity\Articles
articles.id = 1
**articles.comment_ids = '["1","6"]'**
articles.text = ...

table comments \Entity\Comments
comments.id= 2
comments.text = ...

Is this possible?
So the final target is to access the relation through the common public static function relations() method in the Entity class.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions