Basic Query Advice

Morning,

I think i am quite simply having one of those days!

I have a table "customer" in which i store customer data that is created backend.

When a "user" then signs up the give the customer ID which then links the customer data with the user data.

What i would like to do is build a profile page so when the user signs in there customer data is then stored in the cache (i think) so i can then reference it through out the site.

Where would i start with this? my guess is when i log the user in it then runs a function that runs the query and stores the data?

I know this is very vague but a starting point would be nice.

Hi abilham,

I am using the amnah/yii2-user module for my user management functions.

It includes profile functionality that allows you to add whatever additional information you need regarding this user.

Note that is uses a simpler permission model instead of the full RBAC functionality.

As far a caching goes, the database will do some caching for you automatically, and in my case I need user info for almost every web page interaction. I see that the first time I retrieve a user profile it takes longer then subsequent retrievals.

If you need to do more sophisticated caching for some reason, YII2 does have caching functions you can use. Check out the YII2 Guide.

When a user logs in, YII2 will get the user table entry for that user. If you need to get the user profile, you go get that separately.

Remember, as a general rule, every time a user goes to a new page, the system has to load all its data again from scratch. There is very little memory of previous transactions.

-John