You are here

public function FrxOracle::__construct in Forena Reports 8

Object constructor

Parameters

string $uri Database connection string.:

string $repos_path Path to location of data block definitions:

Overrides DriverBase::__construct

File

src/FrxPlugin/Driver/FrxOracle.php, line 36
Oracle specific driver that takes advantage of oracles native XML support

Class

FrxOracle
Class FrxOracle

Namespace

Drupal\forena\FrxPlugin\Driver

Code

public function __construct($name, $conf, DataFileSystem $fileSystem) {
  parent::__construct($name, $conf, $fileSystem);
  $this->db_type = 'oracle';
  $this->use_oracle_xml = FALSE;
  $uri = @$conf['uri'];
  $this->debug = @$conf['debug'];
  if (isset($conf['schema'])) {
    $this->schema = $conf['schema'];
  }
  if (@$conf['oracle_xml']) {
    $this->use_oracle_xml = TRUE;
  }
  if ($uri) {

    // Test for postgres suport
    if (!is_callable('oci_connect')) {
      $this
        ->app()
        ->error('OCI support not installed.', 'OCI support not installed.');
      return NULL;
    }
    try {
      $db = oci_connect($conf['user'], $conf['password'], $uri, @$conf['character_set']);
      $this->db = $db;
    } catch (\Exception $e) {
      $this
        ->app()
        ->error('Unable to connect to database ' . $conf['title'], $e
        ->getMessage());
    }
  }
  else {
    $this
      ->app()
      ->error('No database connection string specified', 'No database connection: ' . print_r($conf, 1));
  }

  // Set the date format that drupal expects using the date api.
  if ($this->db) {
    $stmt = oci_parse($this->db, "ALTER SESSION SET NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'");
    oci_execute($stmt);
    $stmt = oci_parse($this->db, 'ALTER SESSION SET NLS_NUMERIC_CHARACTERS = ".,"');
    oci_execute($stmt);
  }

  // Set up the stuff required to translate.
  $this->te = new SQLReplacer($this);
}