Ejemplo n.º 1
0
 public function __construct($schema_dir)
 {
     $this->db = DB_Helper::getInstance();
     $this->dir = $schema_dir;
     $this->config = DB_Helper::getConfig();
     $this->table_prefix = $this->config['table_prefix'];
     $this->logger = function ($e) {
         echo $e, "\n";
     };
 }
Ejemplo n.º 2
0
// common init for upgrade scripts
define('INSTALL_PATH', dirname(__FILE__) . '/..');
define('CONFIG_PATH', INSTALL_PATH . '/config');
// avoid setup redirecting us
if (!file_exists(CONFIG_PATH . '/setup.php') || !filesize(CONFIG_PATH . '/setup.php') || !is_readable(CONFIG_PATH . '/setup.php')) {
    error_log("ERROR: Can't get setup.php in '" . CONFIG_PATH . "'");
    error_log('Did you forgot to copy config from old install? Is file readable?');
    exit(1);
}
// load init only if no autoloader present
if (!class_exists('DB_Helper')) {
    require_once INSTALL_PATH . '/init.php';
}
$in_setup = defined('IN_SETUP');
global $dbconfig, $db;
$dbconfig = DB_Helper::getConfig();
$db = DB_Helper::getInstance();
function exec_sql_file($input_file)
{
    if (!file_exists($input_file) && !is_readable($input_file)) {
        throw new RuntimeException("Can't read file: {$input_file}");
    }
    global $dbconfig, $db;
    // use *.php for complex updates
    if (substr($input_file, -4) == '.php') {
        $queries = array();
        require $input_file;
    } else {
        $queries = explode(';', file_get_contents($input_file));
    }
    foreach ($queries as $query) {