/**
  * Create database tables from scratch.
  *
  * @return Status
  */
 public function createTables()
 {
     $status = $this->getConnection();
     if (!$status->isOK()) {
         return $status;
     }
     $this->db->selectDB($this->getVar('wgDBname'));
     if ($this->db->tableExists('archive', __METHOD__)) {
         $status->warning('config-install-tables-exist');
         $this->enableLB();
         return $status;
     }
     $this->db->setFlag(DBO_DDLMODE);
     // For Oracle's handling of schema files
     $this->db->begin(__METHOD__);
     $error = $this->db->sourceFile($this->db->getSchemaPath());
     if ($error !== true) {
         $this->db->reportQueryError($error, 0, '', __METHOD__);
         $this->db->rollback(__METHOD__);
         $status->fatal('config-install-tables-failed', $error);
     } else {
         $this->db->commit(__METHOD__);
     }
     // Resume normal operations
     if ($status->isOk()) {
         $this->enableLB();
     }
     return $status;
 }
 /**
  * Apply a SQL source file to the database as part of running an installation step.
  *
  * @param string $sourceFileMethod
  * @param string $stepName
  * @param string $archiveTableMustNotExist
  * @return Status
  */
 private function stepApplySourceFile($sourceFileMethod, $stepName, $archiveTableMustNotExist = false)
 {
     $status = $this->getConnection();
     if (!$status->isOK()) {
         return $status;
     }
     $this->db->selectDB($this->getVar('wgDBname'));
     if ($archiveTableMustNotExist && $this->db->tableExists('archive', __METHOD__)) {
         $status->warning("config-{$stepName}-tables-exist");
         $this->enableLB();
         return $status;
     }
     $this->db->setFlag(DBO_DDLMODE);
     // For Oracle's handling of schema files
     $this->db->begin(__METHOD__);
     $error = $this->db->sourceFile(call_user_func(array($this->db, $sourceFileMethod)));
     if ($error !== true) {
         $this->db->reportQueryError($error, 0, '', __METHOD__);
         $this->db->rollback(__METHOD__);
         $status->fatal("config-{$stepName}-tables-failed", $error);
     } else {
         $this->db->commit(__METHOD__);
     }
     // Resume normal operations
     if ($status->isOk()) {
         $this->enableLB();
     }
     return $status;
 }
示例#3
0
 /**
  * @param DatabaseBase $db
  * @param resource $stmt A valid OCI statement identifier
  * @param bool $unique
  */
 function __construct(&$db, $stmt, $unique = false)
 {
     $this->db =& $db;
     $this->nrows = oci_fetch_all($stmt, $this->rows, 0, -1, OCI_FETCHSTATEMENT_BY_ROW | OCI_NUM);
     if ($this->nrows === false) {
         $e = oci_error($stmt);
         $db->reportQueryError($e['message'], $e['code'], '', __METHOD__);
         $this->free();
         return;
     }
     if ($unique) {
         $this->rows = $this->array_unique_md($this->rows);
         $this->nrows = count($this->rows);
     }
     if ($this->nrows > 0) {
         foreach ($this->rows[0] as $k => $v) {
             $this->columns[$k] = strtolower(oci_field_name($stmt, $k + 1));
         }
     }
     $this->cursor = 0;
     oci_free_statement($stmt);
 }
 function reportQueryError($error, $errno, $sql, $fname, $tempIgnore = false)
 {
     /* Transaction stays in the ERROR state until rolledback */
     if ($tempIgnore) {
         /* Check for constraint violation */
         if ($errno === '23505') {
             parent::reportQueryError($error, $errno, $sql, $fname, $tempIgnore);
             return;
         }
     }
     /* Don't ignore serious errors */
     $this->rollback(__METHOD__);
     parent::reportQueryError($error, $errno, $sql, $fname, false);
 }
 function reportQueryError($error, $errno, $sql, $fname, $tempIgnore = false)
 {
     if ($tempIgnore) {
         /* Check for constraint violation */
         if ($errno === '23505') {
             parent::reportQueryError($error, $errno, $sql, $fname, $tempIgnore);
             return;
         }
     }
     /* Transaction stays in the ERROR state until rolled back */
     if ($this->mTrxLevel) {
         $ignore = $this->ignoreErrors(true);
         $this->rollback(__METHOD__);
         $this->ignoreErrors($ignore);
     }
     parent::reportQueryError($error, $errno, $sql, $fname, false);
 }