public function FrxPostgres::format in Forena Reports 7.4
Same name and namespace in other branches
- 6.2 plugins/FrxPostgres.inc \FrxPostgres::format()
- 6 plugins/FrxPostgres.inc \FrxPostgres::format()
- 7 plugins/FrxPostgres.inc \FrxPostgres::format()
- 7.2 plugins/FrxPostgres.inc \FrxPostgres::format()
- 7.3 plugins/FrxPostgres.inc \FrxPostgres::format()
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
unknown_type $value:
unknown_type $key:
unknown_type $data:
File
- plugins/
FrxPostgres.inc, line 162 - Postgres specific driver that takes advantage of native XML support
Class
- FrxPostgres
- @file Postgres specific driver that takes advantage of native XML support
Code
public function format($value, $key, $raw = FALSE) {
if ($raw) {
return $value;
}
$value = $this
->parmConvert($key, $value);
if ($value === '' || $value === NULL) {
$value = 'NULL';
}
else {
if (is_array($value)) {
if ($value == array()) {
$value = 'NULL';
}
else {
// Build a array of values string
$i = 0;
$val = '';
foreach ($value as $v) {
$i++;
if ($i > 1) {
$val .= ',';
}
$val .= "'" . pg_escape_string($v) . "'";
}
$value = $val;
}
}
elseif (is_int($value)) {
$value = (int) $value;
$value = (string) $value;
}
elseif (is_float($value)) {
$value = (double) $value;
$value = (string) $value;
}
else {
$value = trim($value);
$value = "'" . pg_escape_string($value) . "'";
}
}
return $value;
}