vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Programming Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=188)
-   -   phpinclude tip (for running queries) (https://vborg.vbsupport.ru/showthread.php?t=86846)

Black Vivi 05-01-2003 10:00 PM

phpinclude tip (for running queries)
 
the main problem with phpinclude is running queries, it runs them on every page, even if they're not needed...

using the following you can make it so tey're only ran on certain files:
PHP Code:

if ($PHP_SELF == "/full/files/path/and/file/name/and.extension") {
    
$DB_site->query("YOU\'RE QUERY HERE");


obviously you have to replace a few things (like the file path)

hope it helps some of you ;):D

filburt1 05-03-2003 12:18 AM

You need to use == or that will return true every time. Also $PHP_SELF is depreicated. Finally this is easier:
PHP Code:

if (strpos($_SERVER['PHP_SELF'], "filename.php") != false))
{
    
dowhatever();


Or use PAPI if you want to be really simple.

Black Vivi 05-03-2003 06:54 AM

Quote:

Originally Posted by filburt1
You need to use == or that will return true every time.

i always forget that for some reason...

Quote:

Originally Posted by filburt1
Finally this is easier:
PHP Code:

if (strpos($_SERVER['PHP_SELF'], "filename.php" ) != false))
{
    
dowhatever();



I find it easier to use the full path, seeing as for me it's quite short

Quote:

Originally Posted by filburt1
Or use PAPI if you want to be really simple.

I don't like PAPI, one of my other admins would probably delete all of it, and i just think it's too long...


All times are GMT. The time now is 02:01 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01243 seconds
  • Memory Usage 1,720KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete