0

I have tried using the below code but i keep getting a null reply.

 $user = $collection->findOne(["_id"=> "5ebb4d14ac4ad9500c235a22"]);
    while( $user !==null )
    {

        $arr[]  = array(

            'template'=> $user['template'],
        );
        return ($arr);

    }

i did some research and i think it has something to do with the id being of type object.

Joundill
  • 6,828
  • 12
  • 36
  • 50
  • yes ```new MongoDB\BSON\ObjectID``` worked thanks a lot. i found something similar when i was doing my research but it was only ```new MongoDB("something");``` – Rick Hamton May 14 '20 at 00:05

1 Answers1

0

$user = $collection->findOne(["_id"=> new MongoDB\BSON\ObjectID("5ebb4d14ac4ad9500c235a22")]); worked

Thanks @rjdown.