Tech Off Post

Single Post Permalink

View Thread: Where do you store single pieces of information?
  • User profile image
    jsampsonPC

    In the past I've had to do some things like this for small client sites. I wanted to give them the ability to change "the front page paragraph", "the about us column", and "our slogans on different pages."

    Of course I wouldn't learn of this until things were pretty much finished being developed, so I went with a simple two-column table:

    location
    text

    Examples:

    frontPageParagraph | Hello World
    aboutUsColumn | Hello World Again
    totalMembers | 2878
    websiteCreatedDate | 2008-01-01

    That way I could simply "SELECT text FROM oneLiners WHERE location = 'frontPageParagraph'".

    Again, probably not very elegant, but it worked. Like a previous niner said too, any solution of this type won't give you history, so you could simply toss in an isActive field of type bool, and rather than updating the text field, just insert a new record and give it the exclusive isActive value of True.

    Then it's merely "SELECT text FROM oneLiners WHERE (location = 'frontPageParagraph') AND (isActive = true)"

    Take it with a grain of salt Smiley