samedi 5 décembre 2020

How to Compare two MongoDB ObjectID, == & === using php? [closed]

I am trying to compare two different ObjectIDs of MongoDB with == & === operator but in all case it returns true. when object id is different it still return true.

like - Comparing.

        MongoDB\BSON\ObjectID Object
(
    [oid] => 5fca7fe7082ba613cfee876a
)
yes
MongoDB\BSON\ObjectID Object
(
    [oid] =>  5fca8071082ba613cfee877a
)
yes 

as above example it return true in both cases.

 if($row['_id'] === $row['_id']){

                      echo 'yes';
                  }else{
                      echo 'no';
                  }
                }

If there is any better way to compare please suggest me.

Aucun commentaire:

Enregistrer un commentaire