/** * Find document using it's primary key. * * @param mixed $mongoID Valid MongoId, string value must be automatically converted to * MongoId object. * @param bool $keepChain Only same class or child must be returned, parent document must be * ignored. * @return Document|null * @throws ODMException */ public static function findByPK($mongoID, $keepChain = true) { if (!($mongoID = ODM::mongoID($mongoID))) { return null; } return static::findOne(['_id' => $mongoID], [], $keepChain); }
/** * Fetch one record from database using it's primary key. You can use INLOAD and JOIN_ONLY * loaders with HAS_MANY or MANY_TO_MANY relations with this method as no limit were used. * * @see findOne() * @param mixed $id Primary key value. * @return DocumentEntity|null */ public function findByPK($id) { return $this->findOne(['_id' => $this->odm->mongoID($id)]); }