diff --git a/tools/generate_tables_sql.php b/tools/generate_tables_sql.php index 9f4f06465bc..5c2a3ed704e 100755 --- a/tools/generate_tables_sql.php +++ b/tools/generate_tables_sql.php @@ -23,15 +23,15 @@ // 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)); @@ -39,8 +39,9 @@ $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)); @@ -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"; } diff --git a/tools/generate_tables_sql_and_testNames.php b/tools/generate_tables_sql_and_testNames.php index c1e7cca72b6..cf5151f3fca 100755 --- a/tools/generate_tables_sql_and_testNames.php +++ b/tools/generate_tables_sql_and_testNames.php @@ -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); @@ -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,