Results 1 to 10 of 10
  1. #1
    Join Date
    May 2007
    Posts
    467
    Tokens
    0

    Default fopen() or file_get_contents()

    what one is better faster to use as i am making a template system for my project and i do not know what one i should use or is there any other function that can show content???

  2. #2

    Default

    Why would you not just use MySQL for a template system? Instead of reading flat files?

  3. #3
    Join Date
    May 2007
    Posts
    467
    Tokens
    0

    Default

    so have all the html and css stored in the database?? would that not make the load time big in the sql server?

  4. #4

    Default

    Not unless its like, uber slow, it probably takes more time opening an instance of a file, reading it, then closing it, then it does to pull it ouf ot the database.

    You could have a table called `templates`:

    name
    value

    Example:

    Name: header
    Value: <html><head><title>hey</title></head> <body>


    Name: footer
    Value: <center>Copyright!</center></body></html>

    PHP Code:
    <?php
    function get_template ($template_name) {
        
    $query mysql_query("SELECT name, value FROM templates WHERE name='$template_name' LIMIT 0,1");
        
    $row mysql_fetch_array($query);

        echo 
    $row["value"];
    }
    ?>
    Last edited by MountainDew; 13-01-2008 at 03:27 AM.

  5. #5
    Join Date
    May 2007
    Posts
    467
    Tokens
    0

    Default

    hmm i could do some thing like that then all i have to do is make a template editing system (that would be easy).

    thank you MountainDew.

  6. #6

    Default

    No problem,
    think of it this way.

    When you do it flat-file,

    1. Create connection to the file.
    2. Read the file and store it in the variable.
    3. Close file.

    MySQL (Pre-connected)

    1. Query.
    2. Echo.

  7. #7
    Join Date
    Aug 2007
    Location
    Scotland
    Posts
    13,167
    Tokens
    21,945
    Habbo
    JennyJukes

    Latest Awards:

    Default

    i wanna have ur babiesssssss

    Edited by Agesilaus (Forum Moderator): Please do not post off topic.
    Last edited by Agesilaus; 13-01-2008 at 04:46 AM.


    pigged 25/08/2019



  8. #8
    Join Date
    Jun 2005
    Posts
    2,688
    Tokens
    0

    Latest Awards:

    Default

    Flat file is more efficient for a template system

  9. #9

    Default

    Quote Originally Posted by Baving View Post
    Flat file is more efficient for a template system
    Really?

    I would never have thought that.. I always thought MySQL would be better, and faster.

  10. #10
    Join Date
    May 2007
    Posts
    467
    Tokens
    0

    Default

    i am going mysql as of the this point

    Quote Originally Posted by MountainDew
    No problem,
    think of it this way.

    When you do it flat-file,

    1. Create connection to the file.
    2. Read the file and store it in the variable.
    3. Close file.

    MySQL (Pre-connected)

    1. Query.
    2. Echo.
    and also will be a lot easier for people to skin it as it will have a skinning manager. fast and easy to use.

Posting Permissions

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