Ejemplo n.º 1
0
             $goodVersion = $pdo->isDbVersionAtLeast(nZEDb_MINIMUM_MYSQL_VERSION);
         } catch (\PDOException $e) {
             $goodVersion = false;
             $cfg->error = true;
             $cfg->emessage = 'Could not get version from SQL server.';
         }
         if ($goodVersion === false) {
             $cfg->error = true;
             $cfg->emessage = 'You are using an unsupported version of ' . $cfg->DB_SYSTEM . ' the minimum allowed version is ' . nZEDb_MINIMUM_MYSQL_VERSION;
         }
     }
 }
 // Start inserting data into the DB.
 if (!$cfg->error) {
     $cfg->setSession();
     $DbSetup = new \nzedb\db\DbUpdate(['backup' => false, 'db' => $pdo]);
     try {
         $DbSetup->processSQLFile();
         // Setup default schema
         $DbSetup->loadTables();
         // Load default data files
         $DbSetup->processSQLFile(['filepath' => nZEDb_RES . 'db' . DS . 'schema' . DS . 'mysql-data.sql']);
     } catch (\PDOException $err) {
         $cfg->error = true;
         $cfg->emessage = "Error inserting: (" . $err->getMessage() . ")";
     }
     if (!$cfg->error) {
         // Check one of the standard tables was created and has data.
         $dbInstallWorked = false;
         $reschk = $pdo->query("SELECT COUNT(*) AS num FROM tmux");
         if ($reschk === false) {
Ejemplo n.º 2
0
// TODO Add code here to check permissions on staged files.
//$files = file(nZEDb_ROOT . 'nzedb/build/git-hooks'), FILE_IGNORE_NEW_LINES);
//foreach ($files as $file) {
//	echo "Filename: $file\n";
//}
/**
 * Add all hooks BEFORE the versions are updated so they can be skipped on any errors
 */
if ($error === false) {
    $git = new \nzedb\utility\Git();
    $branch = $git->active_branch();
    if (in_array($branch, $git->mainBranches())) {
        // Only update versions, patches, etc. on specific branches to lessen conflicts
        try {
            // Run DbUpdates to make sure we're up to date.
            $DbUpdater = new \nzedb\db\DbUpdate(['git' => $git]);
            $DbUpdater->newPatches(['safe' => false]);
        } catch (\Exception $e) {
            $error = 1;
            echo "Error while checking patches!\n";
        }
        if ($error === false) {
            try {
                $vers = new \nzedb\utility\Versions();
                $vers->checkAll();
                $vers->save();
                $git->add(nZEDb_VERSIONS);
            } catch (\Exception $e) {
                $error = 1;
                echo "Error while checking versions!\n";
            }