--XX P2.7 ', 1), (8, '2018-11-05', 3, '60601-1', '4.2.1 a) Introduction to RISK MANAGEMENT', '025-<project-number>-XX P3.2.1.1', 3) "), array ($populate_reference_standards, "INSERT INTO reference_standards ( `id-reference_standard_2`, `reference_standard_question`) VALUES ('14971 C.2.1', 'What is the intended use/intended purpose and how is the medical device to be used?'), ('14971 C2.1.1', 'What role is the medical device intended to play in:'), ('[tryREF: 14971-P4.2]', 'test'), ('REF: 14971', 'test'), ('REF: 14971-Annex C', 'test'), ('[REF: 14971-P4.3]', 'test'), ('testREF: 62366 Annex E', 'test') "), array ($populate_reference_items, "INSERT INTO reference_items ( `id-reference`, `question`, `consideration`, `applicable`, `section_hazard`) VALUES (1, 'header=yes', 'Factors to consider for intended user:', 'test', 'test'), (1, 'header=no', 'Mental ability', 'Y', 'S 4.5.2 & S 4.5.3'), (1, 'header=no', 'Physical abilities', 'test', 'test'), (1, 'header=no', 'Skill and Training', 'Y', 'S 4.5.1'), (1, 'test question', 'test consideration', 'testY', 'test section hazard') "), array ($populate_paragraph, "INSERT INTO paragraphs ( `id1_paragraph`, `paragraph_title`) VALUES ('0', 'Preface'), ('1', 'Eerste Hoofdstuk'), ('1.1.', 'en de eerste paragraph'), ('2', 'tweede hoofdstuk'), ('2.1.', 'enz.enz.'), ('2.2.', 'enz.enz.'), ('2.2.2', 'enz.enz.'), ('2.2.3.', 'enz.enz.') ") ); echo '<hr /><h4>View tables, sql stms:</h4>'; foreach($arrTables as $x => $x_value) { //echo "<br /> Tabel naam: " . $arrTables[$x][0] . " <br />SQL statement: " . $arrTables[$x][1]; if (($arrTables[$x][0]==1) || ($create_all_tables == 1)){ //echo '<br /> ===>97create table: ' . $arrTables[$x][1]; fnc_create_table(($arrTables[$x][1]), ($arrTables[$x][2])); } } foreach($arrPopTables as $y => $y_value){ if (($arrPopTables[$y][0]==1) ||$populate_all_tables == 1){ fnc_populate_table($arrPopTables[$y][1]); } } function fnc_populate_table($sql){ global $un, $pw, $dsn; try { $conn = new PDO('mysql:' . $dsn, $un, $pw); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $conn->exec($sql); }catch(PDOException $e) { echo "<br />Connection failed: " . $e->getMessage(); } } function fnc_create_table($create_table, $sql){ global $un, $pw, $dsn; try { $conn = new PDO('mysql:' . $dsn, $un, $pw); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); tableExists($conn, $create_table); $conn->exec($sql); }catch(PDOException $e) { echo "<br />Connection failed: " . $e->getMessage(); } } function tableExists(PDO $pdo, $tableName) { $mrSql = "SHOW TABLES LIKE :table_name"; $mrStmt = $pdo->prepare($mrSql); $mrStmt->bindParam(":table_name", $tableName, PDO::PARAM_STR); $sqlResult = $mrStmt->execute(); if ($sqlResult) { $row = $mrStmt->fetch(PDO::FETCH_NUM); if ($row[0]) { $sql_drop = "DROP TABLE ". $tableName; $stm_drop = $pdo->prepare($sql_drop); $sql_result_drop = $stm_drop->execute(); return $sql_result_drop; } else { return false; } } else { echo("err: ".var_export($pdo->errorInfo(), true)); return false; } } $conn = null;