CIM69 - car database
This commit is contained in:
@@ -2048,4 +2048,47 @@ function getQuestions($type){
|
||||
$view .= '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// convert cartest from history to cartest table
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
function convertCartest(){
|
||||
|
||||
include dirname(__FILE__,2).'/settings/settings.php';
|
||||
|
||||
//GET CARTEST FROM HISTORY TABLE
|
||||
$pdo = dbConnect($dbname);
|
||||
$sql = 'SELECT * FROM history WHERE type="cartest"';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
//Excute Query
|
||||
$stmt->execute();
|
||||
//Get results
|
||||
$messages = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
//FOR EACH CARTEST TRANSFER TO CARTEST TABLE
|
||||
foreach ($messages as $message){
|
||||
//GET VARIABLES
|
||||
$cartest = json_decode($message['description'],true);
|
||||
$carbrand = ucfirst($cartest["CarBrand"]);
|
||||
$cartype = ucfirst($cartest["CarType"]);
|
||||
$questions = json_encode($cartest["Questions"] ??'');
|
||||
$datapoints = json_encode($cartest["plugDataPoints"] ?? '');
|
||||
|
||||
//get header data only
|
||||
unset($cartest["Questions"]);
|
||||
unset($cartest["plugDataPoints"]);
|
||||
$header = json_encode($cartest);
|
||||
|
||||
//INSERT INTO CARTEST
|
||||
$sql = 'INSERT INTO cartest (carbrand, cartype,header,questions,datapoints,createdby) VALUES (?,?,?,?,?,?)';
|
||||
$stmt = $pdo->prepare($sql);
|
||||
//Excute Query
|
||||
$stmt->execute([$carbrand,$cartype,$header,$questions,$datapoints,$cartest["NameTester"]]);
|
||||
|
||||
//MARK HISTORY ITEM FOR DELETATION
|
||||
$sql = 'UPDATE history SET type = "delete" WHERE rowID = '.$message['rowID'];
|
||||
$stmt = $pdo->prepare($sql);
|
||||
//Excute Query
|
||||
$stmt->execute();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user