vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   what does shutdown_query do? (https://vborg.vbsupport.ru/showthread.php?t=75222)

sabret00the 01-27-2005 10:29 AM

what does shutdown_query do?
 
PHP Code:

$DB_site->shutdown_query(

just wondering what this does as opposed to ->query_first and ->query

Creative Suite 01-27-2005 11:45 AM

PHP Code:

    function shutdown_query($query_string$arraykey 0)
    {
        global 
$shutdownqueries;

        if (
NOSHUTDOWNFUNC AND !$arraykey)
        {
            return 
$this->query($query_string);
        }
        elseif (
$arraykey)
        {
            
$shutdownqueries["$arraykey"] = $query_string;
        }
        else
        {
            
$shutdownqueries[] = $query_string;
        }
    } 


sabret00the 01-27-2005 11:52 AM

that went right over my head.

let's simplify

->query( // you'd use for a loop
->query_first( // standard query
->shutdown_query( // ???

Dean C 01-27-2005 12:15 PM

You know what, I have absolutely no idea. It appears that it's a feature designed to run queries after the page has rendered. All the queries in shutdown queries are not run at that particular part of the script I can tell you that. If you look at exec_shut_down() in functions.php you'll see what happens. However, I can't find any reference to that function being run anywhere in any of the vB files :)

Who knows... maybe I'm overlooking something

Marco van Herwaarden 01-27-2005 12:20 PM

Lol, you should read the how-to's :D

https://vborg.vbsupport.ru/showthread.php?t=75207

With great thanks to Bruce.Lee :D :D

Dean C 01-27-2005 12:25 PM

I just checked again, and that function is not being called anywhere according to ultraedit!

Andreas 01-27-2005 12:34 PM

And I thought UltraEdit was a good software ^.^

admincp/global.php
PHP Code:

    if (!empty($cpsession))
    {
        
$DB_site->shutdown_query("
            UPDATE LOW_PRIORITY " 
TABLE_PREFIX "cpsession
            SET dateline = " 
TIMENOW "
            WHERE userid = 
$bbuserinfo[userid]
                AND hash = '" 
addslashes($_COOKIE[COOKIE_PREFIX 'cpsession']) . "'
        "
); 

announcement.php
PHP Code:

if ($anncids)
{
    
$DB_site->shutdown_query("
        UPDATE " 
TABLE_PREFIX "announcement
        SET views = views + 1
        WHERE announcementid IN (
$anncids)
    "
);


attachment.php
PHP Code:

        // doing it as they happen
        
$DB_site->shutdown_query("
            UPDATE " 
TABLE_PREFIX "attachment
            SET counter = counter + 1
            WHERE attachmentid = 
$attachmentinfo[attachmentid]
        "
); 

and so on.

Or did you mean exec_shut_down?

functions.php
PHP Code:

if (!NOSHUTDOWNFUNC)
{
    
register_shutdown_function('exec_shut_down');


PHP Code:

    if (NOSHUTDOWNFUNC)
    {
        
exec_shut_down();
    } 


Dean C 01-27-2005 12:39 PM

No no no no.... ;)

Ok those queries are passed to the method with db_mysql.php, and either ran at that exact time or stored in an array. This array is then released by the method with a global call and acn be used anywhere else in the script. There is then no reference to where-else these queries are ran. So they must be run at that exact point in the script. Do a search for $shutdownqueries and you tell me where they are run, in exec_shut_down. Ok then tell me where this function is ran ;)

Follow?

Andreas 01-27-2005 12:40 PM

Revised my last post to include the references for exec_shut_down

Dean C 01-27-2005 12:57 PM

Weird I don't have those lines in my functions.php?

sabret00the 01-27-2005 12:59 PM

thanks all, that's perfection :)

btw i only just found out you could search folders for strings, that's :cool:

Andreas 01-27-2005 01:01 PM

Hmm, you should have as I just pasted thos from a fresh downloaded archive.
The 2nd is almost at the end of print_output()

Marco van Herwaarden 01-27-2005 01:16 PM

If possible a shutdown function called 'exec_shut_down' is registered with the use of the PHP function 'register_shutdown_function'.

In the function ''exec_shut_down' the queries are executed.

PHP Documentation on 'register_shutdown_function':
Quote:

register_shutdown_function
(PHP 3>= 3.0.4, PHP 4 , PHP 5)

register_shutdown_function -- Register a function for execution on shutdown
Description
void register_shutdown_function ( callback function)


Registers the function named by function to be executed when script processing is complete.

Multiple calls to register_shutdown_function() can be made, and each will be called in the same order as they were registered. If you call exit() within one registered shutdown function, processing will stop completely and no other registered shutdown functions will be called.

The registered shutdown functions are called after the request has been completed (including sending any output buffers), so it is not possible to send output to the browser using echo() or print(), or retrieve the contents of any output buffers using ob_get_contents().

Opmerking: Typically undefined functions cause fatal errors in PHP, but when the function called with register_shutdown_function() is undefined, an error of level E_WARNING is generated instead. Also, for reasons internal to PHP, this error will refer to Unknown() at line #0.

See also auto_append_file, exit(), and the section on connection handling.


All times are GMT. The time now is 09:35 AM.

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

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01571 seconds
  • Memory Usage 1,755KB
  • 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
  • (7)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (13)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