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

MySQL join / missing value for field which was used in join. #983

Closed
nowackipawel opened this issue Apr 5, 2018 · 1 comment
Closed

Comments

@nowackipawel
Copy link
Contributor

nowackipawel commented Apr 5, 2018

I've got entity
User { private int $uId; .... }
and I'm trying to get data for this entity using:
(new UserModel())->join('usertablewithadditionaldata', 'user.uId = usertablewith....uid', 'left')->get()->getResult(\App\Entity\User);

but in that case uId field is null. should be null or it is an error?

@nowackipawel nowackipawel changed the title Joined field entity problem. MySQL join / missing value for field which was used in join. Apr 5, 2018
@lonnieezell
Copy link
Member

It looks like both tables have a uid column? In that case, it could be the table you're joining has an empty uid column that is overwriting the one from the user table.

When joining tables that might have column names in common, you should be explicit in what fields you want to pull, i.e. ->select('user.*') as part of your query.

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

No branches or pull requests

2 participants