Jump to content

Using Includes for Queries


dprichard

Recommended Posts

I have two queries that I will be running at the top of each page on my site once the user is logged in to pull in different information about them and to show the company's information.  Would I be better off having these at the top of each page in the code or having them in includes and calling the includes? 

Link to comment
Share on other sites

If anything is done on many pages, then it is generally better to have them as includes. That way, they can be easily modified if any requirements change. The only thing is you should make sure they are necessary to the file when you include them - otherwise you will be slowing your site down for nothing.

Link to comment
Share on other sites

I would recommend creating a functions.php file and putting your queries in a function and just call that function when you need it, so if you are going to use those functions just use the 'include' keyword to have them brought in to your php file.

Link to comment
Share on other sites

Firstly, no - there are no performance issues with using includes(to the best of my knowledge) since php processes an include as if the code were there in the file.

 

Second, a function is a quite differant thing to an include - however, often people put functions which will be used throughout their site in one file, which they then include where it is needed.

 

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.