So, the time has come to start looking at the SQL in the models.
Simple premise - Loaders are tested and move through grade to be either Bronze, Silver or Gold.
Now a loader is a user, but a user isn't necessarily a loader. A loader is a user who also belongs to "Loading" group, but he/she can also be in other groups.
So I decided, and got my boss's agreement, that we should add the level to the joining table between id_user and id_usergroup (user2usergroup).
This makes it fun though as no programmatically where do I call for the level.
In model user2usergoup - but how do I know the user id. I only want the one!
In model usergroup - but there are many members of the group!
In model user - but the user can be in many groups.
I have opted (today) to go for model user, choosing to specify the id of the usergroup, and write my sql to call out of the joining table with the known $self->id_user().
It works, and with the templating system, selects the correct Medal icon for the level.
Tomorrow, its onto a new page to assign a level to a loader (assuming the forecasted snowfall doesn't hinder me). Although, I do now have the whole thing downloaded onto my MacBook, so I can do some work without internet connections. (Would need to hope that my littl'n will let me though).
That all for today.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment