You are here

public function FrxMSSQL::format in Forena Reports 8

Implement custom SQL formatter to make sure that strings are properly escaped. Ideally we'd replace this with something that handles prepared statements, but it wouldn't work for

Parameters

string $value: The value of the string replacement.

string $key: The token name being replaced.

bool $raw: True implies that data shold not be formatted.

Return value

string Formatted data

File

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

Class

FrxMSSQL
Class FrxMSSQL

Namespace

Drupal\forena\FrxPlugin\Driver

Code

public function format($value, $key, $raw = FALSE) {
  if ($raw) {
    return $value;
  }
  $value = $this
    ->parmConvert($key, $value);
  if ($value === '' || $value === NULL) {
    $value = 'NULL';
  }
  elseif (is_int($value)) {
    $value = (int) $value;
    $value = (string) $value;
  }
  elseif (is_float($value)) {
    $value = (double) $value;
    $value = (string) $value;
  }
  else {
    $value = "'" . str_replace("'", "''", $value) . "'";
  }
  return $value;
}