-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Joining the same table twice #2113
Comments
I'm getting this bug too. Joining the same table/model twice makes phalcon lose an object :(( Extending the model works, but this is definitely a bug |
The solution that works is by extending the User class (in my case) so that class names are unique. class Recruiter extends \Zero\Models\User {
} class Converter extends \Zero\Models\User {
} $query = \Zero\Context\Zero::instance()->modelsManager()->createBuilder()
->columns("RecruitPeople.*,Converter.* ,Recruiter.* ,RecruitClass.*, 'Dummy' as Dummy")
->from(array('RecruitPeople'=>'\Zero\Models\RecruitPeople'))
->innerJoin('\Zero\Models\RecruitClass','RecruitPeople.class_id = RecruitClass.class_id','RecruitClass')
->innerJoin('\Zero\Models\Converter','RecruitPeople.converter_id = Converter.user_id','Converter')
->innerJoin('\Zero\Models\Recruiter','RecruitPeople.recruiter_id = Recruiter.user_id','Recruiter'); So if you need to join the same table more than once, just extend it so that model passed to "join" is unique. |
We are having this issue on the 1.3.3 and the 1.3.2 branch but not on the master. Unit test "testIssue1803" fails. |
Could you please try again using Phalcon 2? |
I tried with Phalcon 2.0.0b and didn't work phpInfo: I viewed the final sql, and the problem is that phalcon doesn't put de columns for this join. The Join statement appears, but not the columns. |
Using Phalcon 2.0.2 I get the same problem. |
@marianacapelo Could you provide a script that we can copy-paste in our machines allowing us to see the problem and reproduce it? |
@andresgutierrez Does this work?
Database simple script
|
The parse has question, I will fix it. |
@dreamsxin great, thanks! |
Fixed in Phalcon 2.0.x |
I am having problems producing the suitable results when joining the same table twice.
The code is the following:
The generated Phql looks correct and is:
The results is always missing the first alias of the User table.
The idea is that RecruitPeople can be converter or recruited by a User, so i need to join twice with User.
I know that in the docs, it's being said that there are some issues with the columns renaming,aliases, but not with tables.
I though about extending the model User to make this properly work, but it's not ideal.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: