You are here

public function FrxDataSource::parmConvert in Forena Reports 7.4

Same name and namespace in other branches
  1. 7.3 FrxDataSource.inc \FrxDataSource::parmConvert()

Perform generic type conversion based on attributes.

Parameters

$key The token key for parameter replacement.:

$value The value of the parameter:

Return value

Ambigous <NULL, array>

5 calls to FrxDataSource::parmConvert()
FrxDrupal::format in plugins/FrxDrupal.inc
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
FrxMSSQL::format in plugins/FrxMSSQL.inc
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
FrxOracle::format in plugins/FrxOracle.inc
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
FrxPDO::format in plugins/FrxPDO.inc
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
FrxPostgres::format in plugins/FrxPostgres.inc
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

File

./FrxDataSource.inc, line 422
Class that defines default methods for access control in an FrxDataSource

Class

FrxDataSource
@file Class that defines default methods for access control in an FrxDataSource

Code

public function parmConvert($key, $value) {
  if (isset($this->types[$key]) && $this->types[$key]) {
    if ($value === NULL || $value === '') {
      $value = NULL;
    }
    else {
      switch (strtolower($this->types[$key])) {
        case 'date':
          $time = @new DateTime($value);
          if ($time) {
            $value = date_format($time, 'Y-m-d H:i:s');
          }
          else {
            $value = NULL;
          }
          break;
        case 'unixtime':
          $time = @new DateTime($value);
          if ($time) {
            $value = $time
              ->getTimeStamp();
          }
          else {
            $value = NULL;
          }
          break;
        case 'numeric':
        case 'float':
          $value = (double) $value;
          break;
        case 'int':
        case 'integer':
          $value = (int) $value;
          break;
        case 'array':
          $value = (array) $value;
          break;
      }
    }
  }
  return $value;
}