Process Post Vars (array)

array key: process_post_vars
returns array

The final step in the waterfall is readying and processing the $post_vars. If editing the form it will need to be populated. If a new record is entered usually it will be emptied. The $post_vars are used to populate the form.

function saturn_tables_cars_process_post_vars($input_form, $query_return, $post_vars) {
	
	global $wpdb;
	
	$id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
	
	if (!$id && $query_return) {
		 //insert
		 $post_vars = array();		 
	} elseif ($id) {
		//update
		if (count($wpdb->get_var("SHOW TABLES LIKE 'saturn_tables_cars'"))) {
			$post_vars = $wpdb->get_row($wpdb->prepare("SELECT id, make, model, mpg, cylinders, weight, model_year, country FROM saturn_tables_cars WHERE id = %d", $id), ARRAY_A);		
		}
	}
	
	return $post_vars;
}