PDA

View Full Version : Storing alot of text...


Exis
01-20-2006, 11:03 PM
I am trying to get everything that I can into mysql tables, or put as many common elements of a page into variables, so I can save space, time, and enable my coworkers to edit the content of our site themselves (just do it through phpmyadmin...as none of them have much knowledge about even basic HTML). I have just about completed this project, and I have 1 final element to input, but I don't know if it would even be correct to do....so here it is:

Each "Building's" page (for each property that we manage) has a description on it. The longest description I have found yet is just shy of 2,000 characters. Would it make sense to put this info into a mysql table with the type "TEXT"? Or would a query that big take too long to retrieve in comparison to just puting the text with the .php file?

Velox Letum
01-21-2006, 05:45 AM
I store far more text per row easily in TEXT columns and it's blazing quick for each retrieval...6 of them are retrieved in about 0.001 seconds (with WHERE) I believe. I store up to 40,000 words per row, though I do compress it (and convert to base64) before storing. I wrote a quick little article about storing large volumes of text (especially compressed) on my blog if you're interested. So I'd say it wouldn't take too long to store and retrieve, perhaps faster than the filesystem, I'm not too sure, but either way it won't hurt to use.

Exis
01-25-2006, 10:20 PM
Cool I decided to go ahead and store the text. Thanks for the advice and explaining what is going on...hate it when all i get is yes/no replies, becuase those don't help me understand anything.

Anyways, I have kind of a followup question. I have variables in an included file on most of my pages that will call a variable like:
$rowd = mysql_fetch_assoc($resultd);
$line_one .= $rowd['Line One'];
And on each of the regular pages, resultd is a slightly different query (based on a buildings name) than the others.

My question then concerns browser chache and how info is pulled. Do I need to add a $line_one .= NULL; to each of my variables in that included file in order to clear it for the next page? Or will those variables "reset" for each page that is loaded? Please explain if browser cache has anything to do with messing up my queries, as they are currently set up...if I did a good enough job of describing the setup clearly :D.

bluegrassjeff
01-26-2006, 09:07 AM
Variables used in php exist on the server, so the browser cache doesn't affect them. The variables will only 'live' through the next page request if you're storing them in a session variable. Otherwise, they just live until the execution of your script completes.

On a related note...if you need to use a variable again, don't use the append operand to set it to null. You can just overwrite the variable with $var = 'new value' or you can destroy the variable completely by calling unset($var).

I hope that answered your question.

Exis
01-26-2006, 08:45 PM
Yeah that answers it. I forgot that php is server-side for some reason, which is a pretty fundamental thing to forget.