O'Reilly logo

PHP 5 Social Networking by Michael Peacock

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Birthdays

Birthdays should be a fairly straightforward feature for us to implement. We need to:

  • Add an additional profile field for the user's birthday
  • Look up the date of birth of our user's contacts
  • Calculate their age
  • Send the data to the calendar
  • Generate the calendar view
  • Display a list of upcoming birthdays to our users

Getting relationship IDs

For us to quickly look up the birthdays of a user's connections, we need to quickly gain access to the IDs of users another user is connected to. We have some similar functionality in our relationships model (models/relationships.php); however, the following method will give us a query returning IDs. We can then use this as a sub query in our birthdays lookup query:

/** * Get IDs of users a user has a relationship ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required