use Doctrine\ORM\EntityManager; use My\Entity\User; $entityManager = EntityManager::create($dbParams, $config); $user = $entityManager->getRepository(User::class)->getInstanceById($userId);
use Joomla\CMS\Factory; use Joomla\CMS\User\User; use Joomla\CMS\User\UserHelper; $userId = Factory::getUser()->id; $user = UserHelper::getInstanceById($userId);This code retrieves the ID of the currently logged in user using the Joomla Factory class, and then retrieves the corresponding User object using the getInstanceById method provided by the UserHelper class. In both of these examples, the getInstanceById method is part of an ORM or data access layer that provides a way to map data from the database to object instances. The Doctrine and Joomla packages are both examples of this type of library.