Exemplo n.º 1
0
 /**
  * @param array $params An associative array with one member:
  *   - connection: An IDatabase connection object
  */
 public function __construct(array $params)
 {
     if (!isset($params['connection'])) {
         throw new InvalidArgumentException("Missing 'connection' argument.");
     }
     $this->db = $params['connection'];
     parent::__construct(['servers' => [['type' => $this->db->getType(), 'host' => $this->db->getServer(), 'dbname' => $this->db->getDBname(), 'load' => 1]], 'trxProfiler' => isset($params['trxProfiler']) ? $params['trxProfiler'] : null, 'srvCache' => isset($params['srvCache']) ? $params['srvCache'] : null, 'wanCache' => isset($params['wanCache']) ? $params['wanCache'] : null]);
     if (isset($params['readOnlyReason'])) {
         $this->db->setLBInfo('readOnlyReason', $params['readOnlyReason']);
     }
 }
Exemplo n.º 2
0
 /**
  * @param IDatabase $db
  * @return string SearchEngine subclass name
  * @since 1.28
  */
 public static function getSearchEngineClass(IDatabase $db)
 {
     switch ($db->getType()) {
         case 'sqlite':
             return 'SearchSqlite';
         case 'mysql':
             return 'SearchMySQL';
         case 'postgres':
             return 'SearchPostgres';
         case 'mssql':
             return 'SearchMssql';
         case 'oracle':
             return 'SearchOracle';
         default:
             return 'SearchEngineDummy';
     }
 }
Exemplo n.º 3
0
 /**
  * Get the full path of a patch file. Originally based on archive()
  * from updaters.inc. Keep in mind this always returns a patch, as
  * it fails back to MySQL if no DB-specific patch can be found
  *
  * @param IDatabase $db
  * @param string $patch The name of the patch, like patch-something.sql
  * @return string Full path to patch file
  */
 public function patchPath(IDatabase $db, $patch)
 {
     global $IP;
     $dbType = $db->getType();
     if (file_exists("{$IP}/maintenance/{$dbType}/archives/{$patch}")) {
         return "{$IP}/maintenance/{$dbType}/archives/{$patch}";
     } else {
         return "{$IP}/maintenance/archives/{$patch}";
     }
 }
Exemplo n.º 4
0
 /**
  * Return a path to the DBMS-specific SQL file if it exists,
  * otherwise default SQL file
  *
  * @param IDatabase $db
  * @param string $filename
  * @return string
  */
 private function getSqlFilePath($db, $filename)
 {
     global $IP;
     $dbmsSpecificFilePath = "{$IP}/maintenance/" . $db->getType() . "/{$filename}";
     if (file_exists($dbmsSpecificFilePath)) {
         return $dbmsSpecificFilePath;
     } else {
         return "{$IP}/maintenance/{$filename}";
     }
 }