-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Overriding $primaryKey does not work with find($id) #1354
Comments
Actually, I tried hacking that file and got rid of the error, but now it's just ignoring the $primaryKey setting. So looks like this capability is broken in the latest version. |
jim5359
changed the title
Undefined index: warehouseId in /Jenssegers/Mongodb/Query/Builder.php:575
Overriding $primaryKey does not work with find()
Nov 16, 2017
jim5359
changed the title
Overriding $primaryKey does not work with find()
Overriding $primaryKey does not work with find($id)
Nov 16, 2017
Awesome @DMNSteve ! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I get the error:
Undefined index: myId in /Jenssegers/Mongodb/Query/Builder.php:575
It looks like the Builder class is hard-coded to expect the key as _id:
return $sequence == '_id' ? $result->getInsertedId() : $values[$sequence];
This causes problems when doing a find($id) when you've modified the primaryKey to be something else in the model class.
public $primaryKey = 'myId';
I'm using the latest master version using PHP7 and Mongo 3.4
The text was updated successfully, but these errors were encountered: