Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kfirba's avatar
Level 50

"Sending" an object based on users profile

Hey.

I have this thing in my application where I can send coupons to users. Currently a coupon has tags and a user can subscribe to tags. Based on that I was getting the coupons for the user.

What I want to do now is to send a coupon based on the users profile. For example, send a coupon only to users who are of age 35+ and are married and live in city X. Ofcourse we can expand on this.

Currently I have 3 tables for a user:

  • users - login data
  • profiles - a users profile
  • addresses - a users address

I also have the following tables to relate users to coupons:

  • users
  • coupons
  • tags
  • tag_user
  • tag_coupon

Now I want to send the coupon based on data from these tables like the example above.

I tried to come up with an idea to do that but I'm just empty right now. No clue how to do so. I don't want to insert potentially 1m rows into the table every time I add a coupon (1 insert query per each user who meet the requirements) because it will be so slow.

Any idea is welcomed!

0 likes
2 replies

Please or to participate in this conversation.