<?php require_once("../../classes/DBConnection.php"); $DB = new DBConnection();

$module = $_POST['module'];
switch($module){
	case "MAYD Cars":
	//Find Max and Min years for each vdsplus
	$col_to_match_t 			= "maptest_mayd_cars";
	$col_to_match				= "vdsplus";
	$col_to_focus_on_t			= "yeartable";
	$col_to_focus_on_for_min 	= "year";
	$col_to_focus_on_for_max 	= "year";
	$col_to_update_t 			= "maptest_mayd_cars";
	$col_to_update_with_min 	= "yearbegin";
	$col_to_update_with_max 	= "yearend";
	require_once("min_and_max.php");

	//go get matches
	$t1_name 		= "maptest_mayd_cars";
	$t1_match_cols 	= array("model_level_one","body_code","fuel_type","capacity","doors","yearbegin","yearend");
	$t1_insert_cols	= array("map");
	$t2_name		= "europe_car_trims";
	$t2_match_cols	= array("model_level_one","body_code","fuel_type","capacity","doors",array('atm_import_start','atm_import_end'), array('atm_import_start','atm_import_end'));
	$t2_pick_cols	= array("id");
	require_once("find_and_load.php");
	break;

	default: echo "<span style='color:#F00'>No matching case for module {$module}</span>";
}

function createTable($tblname, $coldefinitions){
	global $DB;	$sqlpart = "(";
	foreach($coldefinitions as $col => $definition){ $sqlpart .= "`{$col}` {$definition},"; }
	$sqlpart .= "PRIMARY KEY(id)) ENGINE=InnoDB";
	$DB->silentExecute("DROP TABLE IF EXISTS {$tblname}");
	if($DB->silentExecute("CREATE TABLE {$tblname} {$sqlpart}"))
		echo "<span>CREATED TABLE {$tblname}</span><br />";
	else echo "<span style='color:#F00'>Failed to create table {$tblname}</span><br />";
}
?>