Jump to content

Duplicating common queries


MargateSteve

Recommended Posts

Eventually I will have around 5 or 6 queries that will be replicated in several different pages, albeit with a slight difference in each (generally just a change in the WHERE part).

I have been thinking about placing these common queries in a separate file and calling that file with an 'include' on the pages the query is needed.

 

My two questions are....

 

Would this be more beneficial than place the query in the page itself and would there be any downside (as in loading times) if I placed all of these queries in one external file (ie. would this cause all the queries to load each time.

 

Thanks in advance for any advice.

Steve

Link to comment
Share on other sites

I am not at the stage where I have the queries ready, but am just thinking ahead. There is, however, on query that I had help with at http://www.phpfreaks.com/forums/php-coding-help/using-a-generated-row-number-in-another-query that is a good example.

 

In that post I mentioned a League Standings Table. I will have the whole standings in one page whilst, as per that thread, on each teams individual page I would want a smaller version based around that teams rank. Elsewhere I will want a version that only shows records for the last five games of each team, versions that will show just the top five or bottom five teams and various ORDER BY and WHERE variations.

 

So even with that query there will be 6 or 7 slight variations around the site.

 

I have not got into functions yet but if that is the right way to go I will fixed my attention to understanding them.

 

Steve

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.