Jump to content

BB Codes (Pre-Database vs. Post-Database)


Man In Tan

Recommended Posts

I'm building a forum, and I've got a BB code & emoticon parsing script to parse users' posts, but is it better to parse posts before they are written to the database, or after they are loaded from the database? Both options have benefits, but I don't know which is a better option. there seem to be four major differences between the two strategies.With pre-database parsing, we get:

  • Less processing used, because it won't need to be parsed each time the topic is loaded
  • More database space used, because the XHTML is longer than its BB code / emoticon equivalent
  • No on the fly BB codes, such as (user)7(/user), which shows the current name of a user, helpful for referring to a user, who may change their name
  • I'd need to build a de-parser, for when users edit their posts

With post-database parsing, we get:

  • More processing used
  • Less database space used
  • Dynamic BB codes, such as (user)7(/user), which shows the current name of a user, helpful for referring to a user, who may change their name, or (post)561(/post), to quote another's post, without the quote taking up more room in the database
  • No need for a de-parser

Any feedback or suggestions would be greatly appreciated.

Link to comment
Share on other sites

I think the input should be stored as is inputted, and the parsing should happen on the way out. If you ever change the formatting or how you parse it, all the original data will be intact and you won't have to worry about any conversion issues. database data should be as close to the original data as possible, minus any validation and sanitizing before it was put in there.

Link to comment
Share on other sites

Thank you very much for the advice!I thought that would be better, but with all the research on BB codes I've been doing lately, I started to wonder. It seems a lot of people go with a duel database system, and save both the pre- and post-parsed copy of the data, but that seems kind of dumb to me. It seems to me said people are wanting to conserve processing power when displaying the parsed data, but are too lazy to write a de-parser.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...