question about how to store data

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
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

question about how to store data

Post by neophyte »

Okay, I'm building a table to store data for articles to be displayed on my website. It's pretty much built with PHP and mysql. But before I start dumping data into it I have some questions about how/what type of data to store.

Do I store the article blob data with html tags in it? or no tags? Do I store them with html special characters already in place or do I add them later with htmlspecialchars() or htmlentities()?

Or... Is it best to store the data as a simple text string and add <p> tags and images when the article displays?

What say ye?

Thanks
User avatar
Sevengraff
Forum Contributor
Posts: 232
Joined: Thu Apr 25, 2002 9:34 pm
Location: California USA
Contact:

Post by Sevengraff »

what I do is store it as a text field, and keep the data exactly as it was entered by the user (except to add slashes where needed). Apply htmlspecialchars() and other formatting things before it is displayed.

are there advantages to storing it as blob? I have seen some other programs do this. I thought blob was just for binary stuff.
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Blob

Post by neophyte »

Blob question is another good point. What would you use?

In this case their is likely only to be a handful of users who will be adding articles.
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

i store my sites contents in text-fields, and the text is saved as the user inputted, all formatting is done when it's displayed (using bb-code formatting).
Black Unicorn
Forum Commoner
Posts: 48
Joined: Mon Jun 16, 2003 9:19 am
Location: United Kingdom

Post by Black Unicorn »

BLOB is for binary objects, but can contain plaintext too.
I think though that the BLOB type can't hold as much text as a TEXT type. Most common use for BLOB types is storing images, audio or .doc files, which can be rendered later if your output proper MIME types before pasting the data into a document.

Happy dev'ing,
H
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

BLOB is the same size as TEXT, 64K..
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

text

Post by neophyte »

Text seems to be the best option for storing the data. So the question is can anybody recommend a good gpl bb-code class. I was thinking of snagging the one that comes with phpBB. Any ideas?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

evilwalrus also has several.. they aren't the greatest, but a good place to start your own from..
Post Reply