I'm struggling to get my head around the ORM. If we take a trivial example:
I have a twitter like service and I have two tables: user id:int username:string name:string email:varchar[256] bio:text follows follwer:int followed:int (Where these are the IDs for the user table of the relevant users)
How would I do it in the ORM so that I could get, say, the username and bio of everyone that follows a user? Is the ORM the best way to do this?
Thanks!
[ The SQL for that is:
SELECT user.username, user.bio FROM user INNER JOIN follows ON user.id = follows.follower WHERE follows.followed = :my_id ]
Assuming you have defined a Model_User for the users table, and a Model_Follows for the follows table, and defined the correct relation between the two, the query should be: