PDA

View Full Version : fopen() or file_get_contents()



VistaBoy
13-01-2008, 03:07 AM
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???

MountainDew
13-01-2008, 03:17 AM
Why would you not just use MySQL for a template system? Instead of reading flat files?

VistaBoy
13-01-2008, 03:18 AM
so have all the html and css stored in the database?? would that not make the load time big in the sql server?

MountainDew
13-01-2008, 03:23 AM
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
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"];
}
?>

VistaBoy
13-01-2008, 03:30 AM
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.

MountainDew
13-01-2008, 03:34 AM
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.

buttons
13-01-2008, 03:47 AM
i wanna have ur babiesssssss

Edited by Agesilaus (Forum Moderator): Please do not post off topic.

Baving
13-01-2008, 02:24 PM
Flat file is more efficient for a template system

MountainDew
13-01-2008, 02:25 PM
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.

VistaBoy
13-01-2008, 11:08 PM
i am going mysql as of the this point


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.

Want to hide these adverts? Register an account for free!