createTables.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/usr/bin/php -q
  2. <?php
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4 |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2003 The PHP Group |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.02 of the PHP license, |
  9. // | that is bundled with this package in the file LICENSE, and is |
  10. // | available at through the world-wide-web at |
  11. // | http://www.php.net/license/2_02.txt. |
  12. // | If you did not receive a copy of the PHP license and are unable to |
  13. // | obtain it through the world-wide-web, please send a note to |
  14. // | license@php.net so we can mail you a copy immediately. |
  15. // +----------------------------------------------------------------------+
  16. // | Author: Alan Knowles <alan@akbkhome.com>
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: createTables.php 277015 2009-03-12 05:51:03Z alan_k $
  20. //
  21. // since this version doesnt use overload,
  22. // and I assume anyone using custom generators should add this..
  23. define('DB_DATAOBJECT_NO_OVERLOAD', 1);
  24. //require_once 'DB/DataObject/Generator.php';
  25. require_once 'Generator.php';
  26. if (php_sapi_name() != 'cli') {
  27. (new PEAR)->raiseError("\nERROR: You must turn use the cli sapi to run this", null, PEAR_ERROR_DIE);
  28. }
  29. if (!ini_get('register_argc_argv')) {
  30. (new PEAR)->raiseError("\nERROR: You must turn register_argc_argv On in you php.ini file for this to work\neg.\n\nregister_argc_argv = On\n\n", null, PEAR_ERROR_DIE);
  31. exit;
  32. }
  33. if (!@$_SERVER['argv'][1]) {
  34. (new PEAR)->raiseError("\nERROR: createTable.php usage:\n\n" . $_SERVER['argv'][0] . " example.ini\n\n", null, PEAR_ERROR_DIE);
  35. exit;
  36. }
  37. $config = parse_ini_file($_SERVER['argv'][1], true);
  38. foreach ($config as $class => $values) {
  39. $options = &(new PEAR)->getStaticProperty($class, 'options');
  40. $options = $values;
  41. }
  42. $options = &(new PEAR)->getStaticProperty('DB_DataObject', 'options');
  43. if (empty($options)) {
  44. (new PEAR)->raiseError("\nERROR: could not read ini file\n\n", null, PEAR_ERROR_DIE);
  45. exit;
  46. }
  47. set_time_limit(0);
  48. // use debug level from file if set..
  49. DB_DataObject::debugLevel(isset($options['debug']) ? $options['debug'] : 1);
  50. $generator = new DB_DataObject_Generator;
  51. $generator->start();