SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Enthusiast ericd's Avatar
    Join Date
    Nov 2000
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am in the process of upgrading my site, and i wasnt sure if I should use one index file, and have the contents from a mySQL db, or from include files?

    any advice would be great,,

    thanks in advance!!

  2. #2
    Fluffy Kitten Programmer~ Elledan's Avatar
    Join Date
    Jun 2000
    Location
    Netherlands
    Posts
    1,356
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Common elements, like menus and such are usually included from include files, while other parts, like text, are pulled from a database.
    www.nyanko.ws - My web-, software- and game development company.
    www.mayaposch.com - My personal site and blog.

  3. #3
    SitePoint Enthusiast ericd's Avatar
    Join Date
    Nov 2000
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why is it faster to have text from a db rather than a file include? or is that just because it is easier for admin reasions?

  4. #4
    Fluffy Kitten Programmer~ Elledan's Avatar
    Join Date
    Jun 2000
    Location
    Netherlands
    Posts
    1,356
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Storing data (text) in a db is faster and more reliable than storing it into a text file.

    It's faster because you don't have to open a text file every time again.

    I don't know the exact details, but I'm sure that there someone on this forum who wants to explain this more in depth to you
    www.nyanko.ws - My web-, software- and game development company.
    www.mayaposch.com - My personal site and blog.

  5. #5
    SitePoint Evangelist
    Join Date
    Jul 2000
    Location
    Warwickshire, England
    Posts
    557
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think it is just a lot more convenient.
    E.g. put your files in any folder and they will still work, whereas with includes you would need to either specify a full system path or a relative path.
    In some ways it would be more reliable (because mysql automatically takes care of file locking) and easier to secure. Also it is fairly easy to take backups of your whole site.
    Because MySQL doesn't have to find the location of the file on your server each time the page is called, it is a bit faster too. When there re lots of small requests to be made (e.g. while generating forum views in a bulletin board) there is a huge performance increase.
    I dont really know too much about it either, but if you were very inquisitive, you could always download the source code and look at that

  6. #6
    SitePoint Enthusiast ericd's Avatar
    Join Date
    Nov 2000
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the advice, Im going to use mySQL which was my preferred option anyway, I just wanted to make sure i was making the right choice.

    Should I display the contents by
    eg.

    $contents =
    mysql_query("SELECT contents FROM pageContents WHERE page='home'");

    $body_contents = mysql_fetch_array($contents);

    <BODY>

    <?PHP
    echo "$body_contents";
    ?>

    </BODY>

    is this the best way to do it? or is there another way?

    Thanks again.


  7. #7
    ********* wombat firepages's Avatar
    Join Date
    Jul 2000
    Location
    Perth Australia
    Posts
    1,717
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    errr gotta sort of disagree guys,

    for content that is dynamic, ie the contents of this forum, a DB , a fast one anyway such as MySQL is ideal, but in general including text files for static content -headers,navigation,footers and static body content, etc is faster than using the DB and releases load off the db to serve the dynamic content.

    If you have to rewrite the contents as in this forum then again the DB is the more efficient option, but for pages that only you update once in a while includes are gonna be faster.

    Really it depends what your site does/is doing , but note that sites which make use of a total template/db content can have problems under heavy load, Vbulletin is a good example of this - not that I have ever noticed such here at sitepoint!

  8. #8
    SitePoint Wizard edshuck's Avatar
    Join Date
    Jul 2000
    Posts
    1,200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    Lets assume that you are building a site using mysql and php.

    These are the tools I trust and use. font.inc, header.inc, menu.inc are includes.

    for dynamic content, i use php and create the page on the fly, calling includes when needed.

    The Semi-Dynamic page is discussed in part 10 Advanced php of Kevin Yank's Building a Database-Driven Web Site Using PHP and MySQL. The tutorial may be found at: http://www.webmasterbase.com/article.php?aid=228&pid=0
    (in my copy the information needed is on page 103)
    The refernced section is written to reduce the stress on server time. If you have a page that is not changing all the time. For example is not user updated, then the Semi-Dynamic saves lots of server time. Esentially, you load a dynamic page and make it a static page and when requested, load the static page. Updating the page is also covered.
    peace

  9. #9
    SitePoint Enthusiast ericd's Avatar
    Join Date
    Nov 2000
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK thanks everyone, I think i will go for includes now.

    I feel like a tennis ball at the moment,, being thrown here and there!

    but It makes allot more sense to use uncludes for my purpose, since the pages will be rarely updated..

    once again thanks for all your support.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •