public function connect($schema = null)
 {
     $db = parent::connect();
     if ($schema !== null) {
         $db->exec('SET search_path = ' . $schema . ', public');
     }
     return $db;
 }
 /**
  * Called by DatabaseInstaller::getInstaller().
  */
 protected function __construct($url, $user, $pass)
 {
     parent::__construct($url, $user, $pass);
     preg_match('/:([^;]+)/', $url, $matches);
     if (count($matches) < 2) {
         throw new Exception('sqlite database must specify filename');
     }
     $this->dbfile = $matches[1];
 }
 /**
  * Called by DatabaseInstaller::getInstaller().
  */
 protected function __construct($url, $user, $pass)
 {
     parent::__construct($url, $user, $pass);
     preg_match('/dbname=([^;]+)/', $url, $matches);
     if (count($matches) < 2) {
         throw new Exception('"dbname" is required in a mysql connection url');
     }
     $this->dbname = $matches[1];
 }
Esempio n. 4
0
 /**
  * Install step which adds a row to the site_stats table with appropriate
  * initial values.
  *
  * @param $installer DatabaseInstaller
  *
  * @return Status
  */
 public function populateSiteStats(DatabaseInstaller $installer)
 {
     $status = $installer->getConnection();
     if (!$status->isOK()) {
         return $status;
     }
     $status->value->insert('site_stats', array('ss_row_id' => 1, 'ss_total_views' => 0, 'ss_total_edits' => 0, 'ss_good_articles' => 0, 'ss_total_pages' => 0, 'ss_users' => 0, 'ss_images' => 0), __METHOD__, 'IGNORE');
     return Status::newGood();
 }
Esempio n. 5
0
 public function __construct($parent)
 {
     parent::__construct($parent);
 }
Esempio n. 6
0
 public function createTables()
 {
     $status = parent::createTables();
     // Do last-minute stuff like fulltext indexes (since they can't be inside a transaction)
     if ($status->isOk()) {
         $searchindex = $this->db->tableName('searchindex');
         $schema = $this->db->addIdentifierQuotes($this->getVar('wgDBmwschema'));
         try {
             $this->db->query("CREATE FULLTEXT INDEX ON {$searchindex} (si_title, si_text) KEY INDEX si_page ON {$schema}");
         } catch (DBQueryError $dqe) {
             $status->fatal('config-install-tables-failed', $dqe->getText());
         }
     }
     return $status;
 }
Esempio n. 7
0
 /**
  * @return Status
  */
 public function createTables()
 {
     $status = parent::createTables();
     return $this->setupSearchIndex($status);
 }
 public function getGlobalDefaults()
 {
     // The default $wgDBmwschema is null, which breaks Postgres and other DBMSes that require
     // the use of a schema, so we need to set it here
     return array_merge(parent::getGlobalDefaults(), array('wgDBmwschema' => 'mediawiki'));
 }
 /**
  * Overload: after this action field info table has to be rebuilt
  */
 public function createTables()
 {
     $this->setupSchemaVars();
     $this->db->selectDB($this->getVar('wgDBuser'));
     $this->db->setFlag(DBO_DDLMODE);
     $status = parent::createTables();
     $this->db->clearFlag(DBO_DDLMODE);
     $this->db->query('BEGIN fill_wiki_info; END;');
     return $status;
 }
<?php

include_once 'install/DatabaseInstaller.class.php';
include_once 'install-funcs.inc.php';
// Read in DSN
$CONFIG_FILE = '../conf/config.ini';
$CONFIG = parse_ini_file($CONFIG_FILE);
$defaultScriptDir = getcwd() . '/sql/pgsql/';
// Remove the database
$answer = configure('DO_SCHEMA_LOAD', 'Y', "\nWould you like to remove the data for this application");
if (!responseIsAffirmative($answer)) {
    print "Normal exit.\n";
    exit(0);
}
$answer = configure('CONFIRM_DO_SCHEMA_LOAD', 'N', "\nRemoving the data removes any existing database, schema, users, and/or data.\n" . 'Are you sure you wish to continue');
if (!responseIsAffirmative($answer)) {
    print "\nNormal exit.\n";
    exit(0);
}
// Setup root DSN
$username = configure('DB_ROOT_USER', 'root', "\nDatabase adminitrator user");
$password = configure('DB_ROOT_PASS', '', "Database administrator password", true);
$installer = DatabaseInstaller::getInstaller($CONFIG['DB_DSN'], $username, $password);
// Drop tables
$installer->runScript($defaultScriptDir . 'drop_tables.sql');
// Disable postgis
$installer->disablePostgis();
// Drop user
$installer->dropUser(array('SELECT'), $CONFIG['DB_USER']);
// Drop database
$installer->dropDatabase();
// Find schema load file
$schemaScript = configure('SCHEMA_SCRIPT', $defaultScriptDir . DIRECTORY_SEPARATOR . 'create_tables.sql', 'SQL script containing schema definition');
if (!file_exists($schemaScript)) {
    print "The indicated script does not exist. Please try again.\n";
    exit(-1);
}
$dropSchemaScript = configure('SCHEMA_SCRIPT', str_replace('create_tables.sql', 'drop_tables.sql', $schemaScript), 'SQL script containing schema definition');
if (!file_exists($dropSchemaScript)) {
    print "The indicated script does not exist. Please try again.\n";
    exit(-1);
}
// ----------------------------------------------------------------------
// Create Database
// ----------------------------------------------------------------------
include_once 'install/DatabaseInstaller.class.php';
$dbInstaller = DatabaseInstaller::getInstaller($DB_DSN, $username, $password);
// make sure database exists
if (!$dbInstaller->databaseExists()) {
    $dbInstaller->createDatabase();
}
// ----------------------------------------------------------------------
// Create Schema
// ----------------------------------------------------------------------
// run drop tables
$dbInstaller->runScript($dropSchemaScript);
// create schema
$dbInstaller->runScript($schemaScript);
// create read/write user for save
$dbInstaller->createUser(array('SELECT', 'INSERT', 'UPDATE', 'DELETE'), $CONFIG['DB_USER'], $CONFIG['DB_PASS']);
print "Schema loaded successfully!\n";
// ----------------------------------------------------------------------