I am using PDO for getting data from database. I have entities (classes with getters and setters) and Repository what are getting data from daatbase like I have a class Account and using SELECT in AccountRepository and it returns Account object (thanks to PDO and it's setFetchMode(PDO::FETCH_CLASS, Account::class)).
But in database in table accounts I have also a foreign key (Currency_id) to class Currency. How can I get these two classes combined to some object using PDO, so I can use something like $Account->getCurrency()->getName().
Only solution what came to my mind is to get raw data from database using combined select and write own data mapper for new object called like AccountCurrencyCombined. Is it the only solution? What I want to get more complex SQL select where I will use more entities. Do I really have to write my own mapper for every select? Thank you.