// $Id: createTables.php,v 1.24 2006/01/13 01:27:55 alan_k Exp $
//
require_once 'dataobject2/DataObject2.php';
require_once DATAOBJECT2_PATH . 'DataObject2/Generator.php';
if (!ini_get('register_argc_argv')) {
    echo "\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";
    exit;
}
if (!@$_SERVER['argv'][1]) {
    echo "\nERROR: createTable.php usage:\n\nC:\\php\\pear\\DB\\DataObjects\\createTable.php example.ini\nC:\\php\\pear\\DB\\DataObjects\\createTable.php php config.php\n";
    exit;
}
if ($_SERVER['argv'][1] == 'php') {
    require_once $_SERVER['argv'][2];
} else {
    $config = parse_ini_file($_SERVER['argv'][1], true);
    foreach ($config as $class => $values) {
        $options =& PEAR::getStaticProperty($class, 'options');
        $options = $values;
    }
}
$options =& PEAR::getStaticProperty('DB_DataObject2', 'options');
if (empty($options)) {
    echo "\nERROR: could not read config\n\n";
    exit;
}
set_time_limit(0);
// use debug level from file if set..
DB_DataObject2::debugLevel(isset($options['debug']) ? $options['debug'] : 1);
$generator = new DB_DataObject2_Generator();
$generator->start();
 /**
  * Default error handling is to create a pear error, but never return it.
  * if you need to handle errors you should look at setting the PEAR_Error callback
  * this is due to the fact it would wreck havoc on the internal methods!
  *
  * @param  int $message    message
  * @param  int $type       type
  * @param  int $behaviour  behaviour (die or continue!);
  * @access public
  * @return error object
  */
 function raiseError($message, $type = null, $behaviour = null)
 {
     if ($behaviour == PEAR_ERROR_DIE && !empty(DB_DataObject2::$CONFIG['dont_die'])) {
         $behaviour = null;
     }
     $error =& PEAR::getStaticProperty('DB_DataObject2', 'lastError');
     // this will never work totally with PHP's object model.
     // as this is passed on static calls (like staticGet in our case)
     if (isset($this) && is_object($this) && is_subclass_of($this, 'db_dataobject2')) {
         $this->_lastError = $error;
     }
     DB_DataObject2::$LASTERROR = $error;
     // no checks for production here?....... - we log  errors before we throw them.
     DB_DataObject2::debug($message, 'ERROR', 1);
     if (PEAR::isError($message)) {
         $error = $message;
     } else {
         require_once DATAOBJECT2_PATH . '/Error.php';
         $error = PEAR::raiseError($message, $type, $behaviour, $opts = null, $userinfo = null, 'DB_DataObject_Error');
     }
     return $error;
 }
Example #3
0
 public function get($k = null, $v = null)
 {
     parent::get($k, $v);
     return $this;
 }