initializeHMC.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /*
  3. $dbHandle = sqlite_popen("../../../db/data.db", 666, $error);
  4. assert($dbHandle !== FALSE);
  5. $schema_dump = file_get_contents("../../../db/schema.dump");
  6. $ret = sqlite_exec($dbHandle, sqlite_escape_string($schema_dump), $error);
  7. assert($ret == TRUE);
  8. print realpath("../../../db/data.db");
  9. $pdo = new PDO("sqlite:".realpath("../../../db/data.db"));
  10. $sql = file_get_contents(realpath( '../../../db/schema.dump') );
  11. //$sql = str_replace( '?', $sql );
  12. //$st = $pdo->prepare( $sql, array( PDO::ATTR_EMULATE_PREPARES => true ) );
  13. //$st = $pdo->prepare( $sql);
  14. //$st = $pdo->exec("CREATE TABLE Clusters ( cluster_name TEXT PRIMARY KEY, version TEXT, state TEXT )");
  15. //print "\nfirst one".$st;
  16. //$result=$st->execute();
  17. */
  18. //$db = new PDO("sqlite:/var/www/html/KickAssHDPUI/db/data.db");
  19. $db = new PDO("sqlite:".$argv[1]);
  20. // $db = new PDO("sqlite:/tmp/testing1.db");
  21. //print $db->exec("CREATE TABLE Clusters ( cluster_name TEXT PRIMARY KEY, version TEXT, state TEXT )");
  22. //print "\n";
  23. //$ret = $db->exec("CREATE TABLE testing (Id INTEGER)");
  24. #$sql = file_get_contents(realpath( '/var/www/html/KickAssHDPUI/db/schema.dump') );
  25. $sql = file_get_contents(realpath( $argv[2]));
  26. //$sql = file_get_contents(realpath( '/var/www/html/KickAssHDPUI/db/test.dump') );
  27. // print $sql;
  28. /*
  29. $sql = 'BEGIN TRANSACTION;
  30. CREATE TABLE IF NOT EXISTS "Clusters" (
  31. cluster_name TEXT, -- Cluster name
  32. version TEXT, -- version of the hadoop stack installed
  33. state, TEXT, -- cluster state - installed, config in progress etc
  34. PRIMARY KEY (cluster_name)
  35. );
  36. COMMIT;';
  37. */
  38. $db->exec($sql) or die(print_r($db->errorInfo(), true));
  39. //$st = $db->exec("CREATE TABLE Clusters ( cluster_name TEXT PRIMARY KEY, version TEXT, state TEXT )");
  40. /*$st = $db->exec('CREATE TABLE "Clusters" (
  41. cluster_name TEXT, -- Cluster name
  42. version TEXT, -- version of the hadoop stack installed
  43. state TEXT, -- cluster state - installed, config in progress etc
  44. PRIMARY KEY (cluster_name)
  45. );');
  46. print "\nsecondone".$ret;
  47. /*
  48. $dbHandle = new SQLite3("../../../db/data.db", 666, $error);
  49. assert($dbHandle !== FALSE);
  50. $schema_dump = file_get_contents("../../../db/schema.dump");
  51. $ret = $dbHandle->exec(sqlite_escape_string($schema_dump));
  52. assert($ret == TRUE);
  53. */
  54. // Show all information, defaults to INFO_ALL
  55. //phpinfo();
  56. ?>