You are here

public function FrxDataSource::buildFilterSQL in Forena Reports 7.4

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

Build the SQL clause based on builder data.

Parameters

$data:

File

./FrxDataSource.inc, line 390
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 buildFilterSQL($data) {
  $clause = '';
  $op = $data['op'];
  $i = 0;
  if ($data['filter']) {
    foreach ($data['filter'] as $cond) {
      $i++;
      $conj = $i == 1 ? '' : $op . ' ';
      if (isset($cond['filter'])) {
        $clause .= $conj . ' (' . $this
          ->buildFilterSQL($cond) . " )\n";
      }
      else {
        switch ($cond['op']) {
          case 'IS NULL':
          case 'IS NOT NULL':
            $expr = $cond['field'] . ' ' . $cond['op'];
            break;
          default:
            $expr = $cond['field'] . ' ' . $cond['op'] . ' ' . $this
              ->format($cond['value'], $cond['field'], array());
        }
        $clause .= ' ' . $conj . $expr;
      }
    }
  }
  return $clause;
}