diff --git a/README.txt b/README.txt index 752d518..aa83565 100644 --- a/README.txt +++ b/README.txt @@ -338,3 +338,198 @@ the same options. echo httprl_pr($request); ?> + +Get 2 results from 2 different queries at the hook_boot bootstrap level in D6. + + \n" . $y . "
\n"; + unset($x, $y); + + + // Run above 2 queries and get the result via a background callback. + $args = array( + // First query. + array( + 'type' => 'function', + 'call' => 'db_query_range', + 'args' => array('SELECT filename FROM {system} ORDER BY filename ASC', 0, 1), + ), + array( + 'type' => 'function', + 'call' => 'db_result', + 'args' => array('last' => NULL), + 'return' => &$x, + ), + + // Second Query. + array( + 'type' => 'function', + 'call' => 'db_query', + 'args' => array('SELECT filename FROM {system} ORDER BY filename DESC', 0, 1), + ), + array( + 'type' => 'function', + 'call' => 'db_result', + 'args' => array('last' => NULL), + 'return' => &$y, + ), + ); + $callback_options = array(array('return' => ''), &$args); + // Queue up the request. + httprl_queue_background_callback($callback_options); + // Execute request. + httprl_send_request(); + + // Echo what was returned. + echo httprl_pr($x, $y); + ?> + + +Get 2 results from 2 different queries at the hook_boot bootstrap level in D7. + + fields('s', array('filename')) + ->orderBy('filename', 'ASC') + ->range(0, 1) + ->execute() + ->fetchField(); + $y = db_select('system', 's') + ->fields('s', array('filename')) + ->orderBy('filename', 'DESC') + ->range(0, 1) + ->execute() + ->fetchField(); + echo $x . "
\n" . $y . "
\n"; + unset($x, $y); + + // Run above 2 queries and get the result via a background callback. + $args = array( + // First query. + array( + 'type' => 'function', + 'call' => 'db_select', + 'args' => array('system', 's',), + ), + array( + 'type' => 'method', + 'call' => 'fields', + 'args' => array('s', array('filename')), + ), + array( + 'type' => 'method', + 'call' => 'orderBy', + 'args' => array('filename', 'ASC'), + ), + array( + 'type' => 'method', + 'call' => 'range', + 'args' => array(0, 1), + ), + array( + 'type' => 'method', + 'call' => 'execute', + 'args' => array(), + ), + array( + 'type' => 'method', + 'call' => 'fetchField', + 'args' => array(), + 'return' => &$x, + ), + + // Second Query. + array( + 'type' => 'function', + 'call' => 'db_select', + 'args' => array('system', 's',), + ), + array( + 'type' => 'method', + 'call' => 'fields', + 'args' => array('s', array('filename')), + ), + array( + 'type' => 'method', + 'call' => 'orderBy', + 'args' => array('filename', 'DESC'), + ), + array( + 'type' => 'method', + 'call' => 'range', + 'args' => array(0, 1), + ), + array( + 'type' => 'method', + 'call' => 'execute', + 'args' => array(), + ), + array( + 'type' => 'method', + 'call' => 'fetchField', + 'args' => array(), + 'return' => &$y, + ), + ); + $callback_options = array(array('return' => ''), &$args); + // Queue up the request. + httprl_queue_background_callback($callback_options); + // Execute request. + httprl_send_request(); + + // Echo what was returned. + echo httprl_pr($x, $y); + ?> + + +Run a cache clear at the DRUPAL_BOOTSTRAP_FULL level as the current user in a +non blocking background request. + + 'function', + 'call' => 'drupal_bootstrap', + 'args' => array(DRUPAL_BOOTSTRAP_FULL), + ), + array( + 'type' => 'function', + 'call' => 'module_load_include', + 'args' => array('inc', 'system', 'system.admin'), + ), + array( + 'type' => 'function', + 'call' => 'system_clear_cache_submit', + 'args' => array('', ''), + ), + array( + 'type' => 'function', + 'call' => 'watchdog', + 'args' => array('httprl-test', 'background cache clear done', array(), WATCHDOG_DEBUG), + ), + ); + + // Pass the current session to the sub request. + if (!empty($_COOKIE[session_name()])) { + $options = array('headers' => array('Cookie' => session_name() . '=' . $_COOKIE[session_name()] . ';')); + } + else { + $options = array(); + } + $callback_options = array(array('options' => $options), &$args); + + // Queue up the request. + httprl_queue_background_callback($callback_options); + // Execute request. + httprl_send_request(); + ?>