0

I am using the MongoDB driver for PHP and I need to find some nested elements. My structure looks like this:

 proce : { "type" : "cars" , "grupo" : { "_id" : "4e8478ace4b0dea06288ad63"}}

I need to get to the _id = 4e8478ace4b0dea06288ad63

I tried something like

$db->find( array( 'grupo._id' => "4e8478ace4b0dea06288ad63" ) );

but nothing happens.. thanks for your help

1 Answer 1

2

Your basic query looks correct.

However, that grupo._id looks like an ObjectId. Your query is attempting to match a string. Is that "4e84..." number a string or an ObjectId?

You may need to use the PHP MongoId for matching.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much, that was all to making it run =D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.