Method - text

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
deianthropus
Forum Newbie
Posts: 1
Joined: Mon Mar 24, 2008 1:02 pm

Method - text

Post by deianthropus »

I'm currently in the planning stages of my first major PHP project, a site which will deal largely with long blocks of text ranging from 250 - 5,000 words in length. I need to associate each with a set of variables, such as a name, date, keyword, et cetera. Would it be better to store each block in MySQL using long_text, or load each from a plain-text file - and what would be the best method of recalling that text (for example, the URL would need to be a combination of variables, eg date and keyword)? Once again, my knowledge of PHP is limited, and I need to know what would be easiest to implement, integrate with other features, and update when it becomes necessary.
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Re: Method - text

Post by Mordred »

Definitely database. You'll be keeping metadata in it anyway, so it makes sense if the data itself is there.
MySQL wrote:TEXT[(M)] [CHARACTER SET charset_name] [COLLATE collation_name]

A TEXT column with a maximum length of 65,535 (216 – 1) characters.

An optional length M can be given for this type. If this is done, MySQL creates the column as the smallest TEXT type large enough to hold values M characters long.
You will be able to increase the size of the TEXT field without losing data, and you'll be able to index it for full-text search, so you're well-covered.
dhampson
Forum Newbie
Posts: 19
Joined: Mon Mar 24, 2008 8:01 pm

Re: Method - text

Post by dhampson »

Use myql to store the text. I've created a similar site, and it works great. It should work much faster than trying to parse separate files. Plus, you don't need to worry about people changing those files accidentally. (Unless that is a feature you need.)

Stored function in mysql can return custom URLs based on any other field. It's surprisingly easy once you get started.

--Dave
Post Reply