Skip to content

Commit

Permalink
[Tools] Generate tables include path fix
Browse files Browse the repository at this point in the history
  • Loading branch information
laemtl committed Apr 26, 2023
1 parent a2ff03c commit 7fc0fbe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
18 changes: 9 additions & 9 deletions tools/generate_tables_sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,25 @@

// require all relevant OO class libraries
require_once __DIR__ . "/../vendor/autoload.php";
require_once "../php/libraries/Database.class.inc";
require_once "../php/libraries/NDB_Config.class.inc";
require_once "../php/libraries/NDB_BVL_Instrument.class.inc";
require_once __DIR__ . "/../php/libraries/Database.class.inc";
require_once __DIR__ . "/../php/libraries/NDB_Config.class.inc";
require_once __DIR__ . "/../php/libraries/NDB_BVL_Instrument.class.inc";

// Get command line options
$opts = getopt("D");

$fp = fopen("ip_output.txt", "r");
$data = fread($fp, filesize("ip_output.txt"));
$fp = fopen(__DIR__ . "/ip_output.txt", "r");
$data = fread($fp, filesize(__DIR__ . "/ip_output.txt"));
fclose($fp);

$instruments = explode("{-@-}", trim($data));

$tblCount = 0;
$parameterCount = 0;
foreach ($instruments as $instrument) {
$catId = "";
$items = explode("\n", trim($instrument));
$catId = "";
$output = "";
$items = explode("\n", trim($instrument));
foreach ($items as $item) {
$paramId = "";
$bits = explode("{@}", trim($item));
Expand All @@ -55,8 +56,7 @@
// generate the CREATE TABLE syntax
case "table":
$tablename = $bits[1];
$filename = "../project/tables_sql/".$tablename.".sql";
$output = "";
$filename = __DIR__ . "/../project/tables_sql/".$tablename.".sql";
if (isset($opts["D"])) {
$output = "DROP TABLE IF EXISTS `$tablename`;\n";
}
Expand Down
11 changes: 6 additions & 5 deletions tools/generate_tables_sql_and_testNames.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

// require all relevant OO class libraries
require_once __DIR__ . "/../vendor/autoload.php";
require_once "../php/libraries/Database.class.inc";
require_once "../php/libraries/NDB_Config.class.inc";
require_once "../php/libraries/NDB_BVL_Instrument.class.inc";
require_once __DIR__ . "/../php/libraries/Database.class.inc";
require_once __DIR__ . "/../php/libraries/NDB_Config.class.inc";
require_once __DIR__ . "/../php/libraries/NDB_BVL_Instrument.class.inc";

$data = stream_get_contents(STDIN);

Expand All @@ -38,14 +38,15 @@
foreach ($items as $item) {
$paramId = "";
$bits = explode("{@}", trim($item));
print_r($bits);
if (preg_match("/Examiner[0-9]*/", $bits[1])) {
continue;
}
switch ($bits[0]) {
// generate the CREATE TABLE syntax
// generate the CREATE TABLE syntax
case "table":
$tablename = $bits[1];
$filename = "../project/tables_sql/".$tablename.".sql";
$filename = __DIR__ . "/../project/tables_sql/".$tablename.".sql";
$output = "CREATE TABLE `$tablename` (
`CommentID` varchar(255) NOT NULL default '',
`UserID` varchar(255) default NULL,
Expand Down

0 comments on commit 7fc0fbe

Please # to comment.