anthonygauthier / MySimpleORM

Simple, lightweight and effective PHP ORM using MySQLi.
MIT License
7 stars 4 forks source link

Relations between tables? #11

Closed pwFoo closed 3 years ago

pwFoo commented 4 years ago

Is it possible to handle relations for example to get a post with the authors details by relation author_id -> user_id?

anthonygauthier commented 4 years ago

This should already be taken care of actually. But it does it to a very low level as it will only do INNER JOIN, therefore, if there are rows only attainable via LEFT or RIGHT JOIN - it won't work as expected.

https://github.com/delirius325/MySimpleORM/blob/8d349eb9d1eb90141529a38ebb8429dd75ac2a5d/src/MySimpleORM/Mapper/Database.php#L409-L450

Below is the function that takes care of the relations between tables. We could try to think of a way to implement logic for LEFT + RIGHT joins.