quick question -- bb-code

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
darkzerox
Forum Newbie
Posts: 3
Joined: Wed Jul 13, 2005 3:20 pm

quick question -- bb-code

Post by darkzerox »

i've made a script that allows the user to easily edit any webpage via bb-code.
when the user edits a page, it saves the script as it is (in bb-code).
and only on page-load is it converted to html.
my question is, would it better to convert it to html when saving?
in this case, when the user wants to edit the page again, i would have to convert it back to bb-code, from html.
or should i save two copies of it? one in html (for viewing) and one in bb-code (for editting)

it's currently saved as a text file....
i could try using mysql, i dont know if that would speed things up tho, and im not too familiar with it.

what do you guys suggest?
RobertPaul
Forum Contributor
Posts: 122
Joined: Sun Sep 18, 2005 8:54 pm
Location: OCNY

Post by RobertPaul »

I would say convert it to HTML when saving the editing rather than serving the page. This will likely speed things up, because you won't have to convert it every time the page is served up.
darkzerox
Forum Newbie
Posts: 3
Joined: Wed Jul 13, 2005 3:20 pm

Post by darkzerox »

yeah, i thought so, but it's so small, it hardly takes anytime.
anyways, i think i'll do that.. or maybe on the next site i make.. haha.
thanks for your speedy & helpful reply :)
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I don't think there is a point converting it to html when storing it, although it may speed things up a little.. this especially depends on how you actually convert to html. For example, if your using eregi over preg_replace then that would slow it down a lot more. Databases are generally much easier to maintain and optimize rather than flatfiles, especially when dealing with lots of data.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I prefer to store the original, store the converted and store a timestamp of the last update to the record. If any changes are made to how bbcode operates, you may want to rerun all "files" older than the bbcode change time. Assuming you want to store all the data in the database, it'll easily keep the best of both worlds, ultra fast display, and easily editable.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

As usual, the choice between memory and cpu usage :)

1-) Only store the text with bbcode. And generate the html each time the text is requested.
2-) Store a text and a html version. The text version is used for editting and the html version is used for output.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

memory
You know, my dad has this thing against using "memory" when you're referring to disk space: he claims that it means RAM, so you shouldn't use memory.

Ah well.
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

Memory is RAM.. Random Access Memory.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Actually, i wasn't referring to a specific storage medium (be it ram, harddisk, ...) I really meant Memory.
Post Reply