SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Activity Logger

  1. #1
    SitePoint Addict eanimator's Avatar
    Join Date
    Sep 2005
    Posts
    396
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Activity Logger

    Hello,

    I need to know this:

    Best way to develop

    RECENT ACTIVITY LOG

    Tom wrote on John's Wall.
    Tom likes Munim's photo.
    Tom and Munim are now friends.


    would it be fine to construct a string "Tom wrote on John's Wall." at the time of insertion? or else I have to do Table JOINS everytime I want to display activities

    Here is my table structure:
    PHP Code:
    CREATE TABLE `user_activity` (
      `
    activityIDint(11NOT NULL auto_increment,
      `
    activity_typeint(11NOT NULL,
      `
    recordIDint(11NOT NULL,
      `
    hostuserIDint(11NOT NULL,
      `
    targetuserIDint(11NOT NULL,
      `
    activity_datedatetime NOT NULL,
      `
    activityvarchar(255NOT NULL,
      
    PRIMARY KEY  (`activityID`),
      
    KEY `recordID` (`recordID`),
      
    KEY `userID` (`hostuserID`),
      
    KEY `activity_type` (`activity_type`)
    ENGINE=MyISAM 
    activity = constructed string.

    Awaiting your response.

    Thanks in advance

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2002
    Location
    Bristol, UK
    Posts
    2,240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I wouldn't store the strings themselves in the database. I would store them separately in a format like this:

    Code:
    %s wrote on %s's wall
    %s commented on %s's photo
    You could then use whatever string replacement functions your application language supports to fill in the blanks when you display each item.

    The advantage of using this method is if you wanted to change all occurrences of a specific type of activity, there's only one string to edit as opposed to potentially thousands of rows in a database table. This also allows the possibility of supporting multiple languages in the future.

  3. #3
    SitePoint Addict eanimator's Avatar
    Join Date
    Sep 2005
    Posts
    396
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks!!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •