2014-01-14	Tim Dietrich
				Initial version.	
				
		Comments:		
		
			The form itself includes a call to the fmExecuteSQL function, using a static SELECT statement 
			to generate the list of the states referenced in the database. 
			
			It also makes use of FMWebFrame's caching function. If available, the list of states
			is pulled from the cache.
*/
// Initialize the request.
require_once dirname(__FILE__) . '/../FMWebFrame/FMWebFrame.php';
// Check to see if there is a list of states in the cache.
$states_cache = fmCacheGet('states');
// If there is no cached list of states, or the cache is more than 30 days old...
if ($states_cache === null or $states_cache['Cache_Age'] > 60 * 60 * 24 * 30) {
    // Get a list of the states that are referenced in the Contacts table.
    $states = fmExecuteSQL($fmDemo, 'SELECT DISTINCT State FROM Contacts ORDER BY State');
    // Cache the list.
    fmCachePut($states, 'states');
} else {
    // Get the content of the cache.
    $states = $states_cache['Cache_Contents'];
}
// Set page title.
$ui_title = "FMWebFrame Demo | ExecuteSQL";
// Start output buffering.
ob_start();
?>
		
			2014-01-14	Tim Dietrich
				Initial version.	
				
		Comments:		
			None.
*/
// Initialize the request.
require_once dirname(__FILE__) . '/../FMWebFrame/FMWebFrame.php';
// Get the start time.
$current_time = microtime();
$current_time = explode(' ', $current_time);
$current_time = $current_time[1] + $current_time[0];
$page_start_time = $current_time;
// Try to get the data from the cache.
$state_counts_cache = fmCacheGet('state_counts_' . $_GET['uuid']);
// Get the stop time.
$current_time = microtime();
$current_time = explode(' ', $current_time);
$current_time = $current_time[1] + $current_time[0];
$page_stop_time = $current_time;
// Get the elapsed time.
$page_elapsed_time = round($page_stop_time - $page_start_time, 4);
// If there is no cached list of states, or the cache is more than 30 days old...
if ($state_counts_cache === null or $state_counts_cache['Cache_Age'] > 60 * 60 * 24 * 30) {
    // Redirect back to the "no cache" step.
    require_once 'cache-handler-no-cache.php';
    die;
} else {
    // Get the contents of the cache.
    $state_counts = $state_counts_cache['Cache_Contents'];