Dan_Burt
(Dan Burt)
3
What a coincidence! Just as I was looking for a guide for using PHP with MongoDB, this was published a few days before I found it!
Its a good and comprehensive introduction, thanks. I had to adjust this, to use a Docker container for the PHP (and Apache) server, rather than on a local Mac machine.
I published my working / final image to Docker Hub:
redswitch/php-mongodb:8.0-1.9.0
(PHP 8.0 with MongoDB client 1.9.0)
Can I ask how you would insert a related / linked document? 2 collections, with a 1-to-Many relationship between them.
I dont know where to start. I expect I will need to query the parent collection to get the object ID, then use that as 1 of the fields / properties in an InsertOne() request?
Is it possible to use a simple PHP variable containing the object ID in the same way as just a String variable?
2 Likes