Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 7th, 2003, 08:11 PM
Registered User
 
Join Date: Jun 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.
 
Old July 8th, 2003, 11:45 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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/
 
Old July 8th, 2003, 12:03 PM
Registered User
 
Join Date: Jun 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

But which one has a higher efficiency in speed?
Thanks for your answer~:D
 
Old July 8th, 2003, 12:31 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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/
 
Old July 8th, 2003, 10:43 PM
Registered User
 
Join Date: Jun 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks yoru answer
I wil try it~:D





Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help Making Charts. chobo2 C# 2005 20 March 8th, 2008 05:45 PM
Basic- Making a template call / Date Arithmetic presack XSLT 2 August 3rd, 2007 01:33 PM
Making the connection... B14speedfreak Java Databases 2 November 12th, 2006 01:49 PM
calling one template in other template VijayKumar XSLT 3 September 15th, 2005 11:12 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.