Hello. I have recently started using User Cake for an online portal. I’ve primarily been working with one specific table (the user table), but I need to be able to reference another table based on a certain field.
Here’s the scenario. Each user is assigned an ID. I have a second “accounts” table, each having a field corresponding to a user (using that ID number). I have created a page that they can click on that will tell them how many accounts are linked to them, but I don’t have any idea where to start with the query that will return the results. Some users many have only 1 related account, while others may have 20. I think it needs to be something like select “accountname” from “accounts” where “id=($loggedInUser->id)” and then somehow tell it to list the information for me.
Some guidance would be helpful as I’m not sure of the exact syntax to use and the SQL tutorials that I’ve found on the internet are too vague for me.