Database Array Explode/Implode #4673
Replies: 1 comment 5 replies
-
e107 is currently not normalizing data correctly, so I recommend against storing data like how e107 saves Suppose you have an Author and many Books. To model that a Book belongs to an Author, you add a column
Author then has many books:
But what if you wanted to connect two tables together so that they each have many of each other? A Physician has many Patients through Appointments, and a Patient also has many Physicians through Appointments. Your database schema should look like this, then:
To fix e107 userclasses, a third table,
This model would mean that an |
Beta Was this translation helpful? Give feedback.
-
I've been wondering about this for years now, and have asked around but still I don't understand how this works.
I have a service records plugin, which stores data of users, some of the details stored are in an array (kind of like userclasses in the user database), It saves unique id's from other tables. which would end up looking like (1,4,15,22, etc...).
I want to show the details in the user profile, however I can't wrap my head around it. explode/implode - if I explode the array, how would I link the numbers(id's) to the other database to return their name, or other information?
Since it's similar to userclasses, I've been digging around the code and end up null on my end.
---- Alright, time for a better example. I think....
So I have a list of "Advanced Clone Training" <--- name doesn't really matter for this - With this is a list of "Trainings" that a unit would have created for their members to do, etc....
In the database is looks like this:
Now for the unit, there is a service records area, which allows administrators to edit a member's service record to keep it up to date, etc...
That is stored as:
What I'd want to do is display that service record information on the user profile page. However, I'm use to do it like Jimmi08 said, in one query (but I know it can't be done, this is why I asked).
Beta Was this translation helpful? Give feedback.
All reactions