View Full Version : what does shutdown_query do?
sabret00the
01-27-2005, 10:29 AM
$DB_site->shutdown_query(" just wondering what this does as opposed to ->query_first and ->query
Creative Suite
01-27-2005, 11:45 AM
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
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
if ($anncids)
{
$DB_site->shutdown_query("
UPDATE " . TABLE_PREFIX . "announcement
SET views = views + 1
WHERE announcementid IN ($anncids)
");
}
attachment.php
// 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
if (!NOSHUTDOWNFUNC)
{
register_shutdown_function('exec_shut_down');
}
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':
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.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.