getting whole page from database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
legaxy
Forum Newbie
Posts: 19
Joined: Thu Mar 20, 2003 3:26 am
Location: Auckland, New Zealand
Contact:

getting whole page from database

Post by legaxy »

I have found my site is beginning to get too big, too many files, becomes confusing when using login forums due to the structure of links and location of files. :(
I am planning to put all the page contents in the mysql db and just pull it out using variables like in index.php?page=...
I want to know is this safe to do, how would its speed compare to using the flat files? what type of column should I use? Blob, longtext ... or...? :?

and can i just dump the whole php file into a db field and not need to edit it?

Thanks all!

btw...
planning to use

Code: Select all

<?php
SELECT from pages where page = $page
?>
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Re: getting whole page from database

Post by []InTeR[] »

legaxy wrote:what type of column should I use? Blob, longtext ...
Type's:
  1. * Char Max 265 chars
    * TinyText Max 264 chars (not sure)
    * Text Max 65535 chars
    * MediumText Max 16777215 chars
    * LongText Max 4294967295 chars
Just look what the biggest file is, an take your pick.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

complete pages/scripts in the database... I don't like that very much.

http://www.php.net/manual/en/configurat ... epend-file may help to prevent you from forgetting the login part (can be done in .htaccess for certain directories if you like).
You might also put all files in a .htaccess protected directory with allow None permission and have an index.php that dispatches all requests (include will still work)
Jim
Forum Contributor
Posts: 238
Joined: Fri Apr 19, 2002 5:26 am
Location: Near Austin, Texas

Post by Jim »

If you get a lot of hits, pulling information from your mysql db every time someone wants to access a page will be a bit straining and resource intensive.

I suggest you just run through your files, find a better way to organize them (use sensible directories and filenames) and re-do the links. It'll probably take less than or as much time as it would to enter all these articles in the database, and it will save you some loading time as well.
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

Maybe you must download a good CMS in php?

@ my work, the php and html is totally seppareted.
And all that thnx to Yapter.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

I had the same dilemma, I ended up picking to use .inc/.php files rather than mysql db with contents because like Jim said, it slowed my server down considerably when it got busy.
airo
Forum Commoner
Posts: 31
Joined: Thu Apr 24, 2003 4:07 pm

Post by airo »

Jim wrote:If you get a lot of hits, pulling information from your mysql db every time someone wants to access a page will be a bit straining and resource intensive.

I suggest you just run through your files, find a better way to organize them (use sensible directories and filenames) and re-do the links. It'll probably take less than or as much time as it would to enter all these articles in the database, and it will save you some loading time as well.
Just to elaborate on this abit further, i think its either 7 or 17 simultaneous(sp?) page views before a mysql DB starts to get a workload.
Post Reply