|
 |
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
|
 |
|
|
 |

July 7th, 2003, 08:11 PM
|
Registered User
|
|
Join Date: Jun 2003
Location: , Hong Kong, Hong Kong.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Making a template , Which one is better?
I have four way:
1. Use files to store the template,every times when i use, i need to read the files, but the speed may be very slow.
2. Use ONE file to store whole template,every times when i use, i need to read it. I am afraid it will increase the usage of the server because the file may be very big.
3. Use file first,then read them and store in the database at first ,when it is necessary , we can update the database 's data, every times when we need , we can read from the database , but i am afraid it will increase the usage of the mysql server when it is many people.
4. All the things store in the database , but it is not easy to edit the template.
|

July 8th, 2003, 11:45 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
What do you mean by template?
If you have ANY data that needs to be read, then it will be read. Whether you store this data in several small files, one big file, in a database, etc., you're still going to read the data.
Take care,
Nik
http://www.bigaction.org/
|

July 8th, 2003, 12:03 PM
|
Registered User
|
|
Join Date: Jun 2003
Location: , Hong Kong, Hong Kong.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
But which one has a higher efficiency in speed?
Thanks for your answer~:D
|

July 8th, 2003, 12:31 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Well, that all depends on your setup. The easiest way to tell what's the fastest is to test it yourself.
Write four PHP scripts where the only difference is where your template files get read. Time the scripts. Run each test at least 50-100 times to get an average reading. Compare the results.
See http://www.php.net/microtime for a useful function in writing timed scripts.
If you're running your database on the same machine as your webserver, I doubt you'll see much of a difference either way. As soon as you put your database on a different machine, things get a little slower because you have to add a network connection to the mix. It's not terribly noticeable as long as your database server is in the same physical network as your webserver. Also, having your database on it's own server means that it can fully utilize the memory in that machine to cache query results, so running a bunch of similar queries should be really fast.
It all boils down to this: there are too many variables to just say "this is the fastest way to do things."
Take care,
Nik
http://www.bigaction.org/
|

July 8th, 2003, 10:43 PM
|
Registered User
|
|
Join Date: Jun 2003
Location: , Hong Kong, Hong Kong.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks yoru answer
I wil try it~:D
|
Thread Tools |
Search this Thread |
|
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |