Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing hasMany() without foreign key #289

Open
mmethner opened this issue Apr 5, 2019 · 1 comment
Open

Accessing hasMany() without foreign key #289

mmethner opened this issue Apr 5, 2019 · 1 comment
Labels

Comments

@mmethner
Copy link

mmethner commented Apr 5, 2019

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.

@FlipEverything
Copy link
Contributor

Unfortunately I don't know the answer to that, but I don't think so....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants