You are here

public function FrxMSSQL::__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/FrxMSSQL.php, line 36
Oracle specific driver that takes advantage of oracles native XML support

Class

FrxMSSQL
Class FrxMSSQL

Namespace

Drupal\forena\FrxPlugin\Driver

Code

public function __construct($name, $conf, DataFileSystem $fileSystem) {
  parent::__construct($name, $conf, $fileSystem);
  $this->db_type = 'mssql';
  $this->use_mssql_xml = FALSE;
  $uri = $conf['uri'];
  $this->debug = $conf['debug'];
  if ($conf['mssql_xml']) {
    $this->use_mssql_xml = TRUE;
  }
  if ($uri) {

    // Test for mssql suport
    if (!is_callable('mssql_connect')) {
      $this
        ->app()
        ->error('MSSQL support not installed.', 'MSSQL mssql support not installed.');
      return NULL;
    }
    try {
      ini_set('mssql.textlimit', 2147483647);
      ini_set('mssql.textsize', 2147483647);
      $db = mssql_connect($uri, $conf['user'], $conf['password']);
      $this->db = $db;
      if ($db) {
        mssql_select_db($conf['database'], $db);
        mssql_query("SET QUOTED_IDENTIFIER ON");
      }
    } 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 up the stuff required to translate.
  $this->te = new SQLReplacer($this);
}