initializeHMC.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /*
  3. *
  4. * Licensed to the Apache Software Foundation (ASF) under one
  5. * or more contributor license agreements. See the NOTICE file
  6. * distributed with this work for additional information
  7. * regarding copyright ownership. The ASF licenses this file
  8. * to you under the Apache License, Version 2.0 (the
  9. * "License"); you may not use this file except in compliance
  10. * with the License. You may obtain a copy of the License at
  11. *
  12. * http://www.apache.org/licenses/LICENSE-2.0
  13. *
  14. * Unless required by applicable law or agreed to in writing,
  15. * software distributed under the License is distributed on an
  16. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  17. * KIND, either express or implied. See the License for the
  18. * specific language governing permissions and limitations
  19. * under the License.
  20. *
  21. */
  22. /*
  23. $dbHandle = sqlite_popen("../../../db/data.db", 666, $error);
  24. assert($dbHandle !== FALSE);
  25. $schema_dump = file_get_contents("../../../db/schema.dump");
  26. $ret = sqlite_exec($dbHandle, sqlite_escape_string($schema_dump), $error);
  27. assert($ret == TRUE);
  28. print realpath("../../../db/data.db");
  29. $pdo = new PDO("sqlite:".realpath("../../../db/data.db"));
  30. $sql = file_get_contents(realpath( '../../../db/schema.dump') );
  31. //$sql = str_replace( '?', $sql );
  32. //$st = $pdo->prepare( $sql, array( PDO::ATTR_EMULATE_PREPARES => true ) );
  33. //$st = $pdo->prepare( $sql);
  34. //$st = $pdo->exec("CREATE TABLE Clusters ( cluster_name TEXT PRIMARY KEY, version TEXT, state TEXT )");
  35. //print "\nfirst one".$st;
  36. //$result=$st->execute();
  37. */
  38. //$db = new PDO("sqlite:/var/www/html/KickAssHDPUI/db/data.db");
  39. $db = new PDO("sqlite:".$argv[1]);
  40. // $db = new PDO("sqlite:/tmp/testing1.db");
  41. //print $db->exec("CREATE TABLE Clusters ( cluster_name TEXT PRIMARY KEY, version TEXT, state TEXT )");
  42. //print "\n";
  43. //$ret = $db->exec("CREATE TABLE testing (Id INTEGER)");
  44. #$sql = file_get_contents(realpath( '/var/www/html/KickAssHDPUI/db/schema.dump') );
  45. $sql = file_get_contents(realpath( $argv[2]));
  46. //$sql = file_get_contents(realpath( '/var/www/html/KickAssHDPUI/db/test.dump') );
  47. // print $sql;
  48. /*
  49. $sql = 'BEGIN TRANSACTION;
  50. CREATE TABLE IF NOT EXISTS "Clusters" (
  51. cluster_name TEXT, -- Cluster name
  52. version TEXT, -- version of the hadoop stack installed
  53. state, TEXT, -- cluster state - installed, config in progress etc
  54. PRIMARY KEY (cluster_name)
  55. );
  56. COMMIT;';
  57. */
  58. $db->exec($sql) or die(print_r($db->errorInfo(), true));
  59. //$st = $db->exec("CREATE TABLE Clusters ( cluster_name TEXT PRIMARY KEY, version TEXT, state TEXT )");
  60. /*$st = $db->exec('CREATE TABLE "Clusters" (
  61. cluster_name TEXT, -- Cluster name
  62. version TEXT, -- version of the hadoop stack installed
  63. state TEXT, -- cluster state - installed, config in progress etc
  64. PRIMARY KEY (cluster_name)
  65. );');
  66. print "\nsecondone".$ret;
  67. /*
  68. $dbHandle = new SQLite3("../../../db/data.db", 666, $error);
  69. assert($dbHandle !== FALSE);
  70. $schema_dump = file_get_contents("../../../db/schema.dump");
  71. $ret = $dbHandle->exec(sqlite_escape_string($schema_dump));
  72. assert($ret == TRUE);
  73. */
  74. // Show all information, defaults to INFO_ALL
  75. //phpinfo();
  76. ?>