Answer the question
In order to leave comments, you need to log in
How to get a field by id in mongoDb if id is not an object?
Tell me how you can get the field by _id if _id is not ObjectId
If you save _id in the database as an object (ObjectId("11b12aa654bce41356002559")), then everything works, but if I want to set it myself, that is, just as a string ("11b12aa654bce41356002559") then this scheme finds nothing.
$product = Products::findOne(['_id' => '11b12aa654bce41356002559']);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question