public function FrxDrupal::format in Forena Reports 6.2
Same name and namespace in other branches
- 6 plugins/FrxDrupal.inc \FrxDrupal::format()
- 7 plugins/FrxDrupal.inc \FrxDrupal::format()
- 7.2 plugins/FrxDrupal.inc \FrxDrupal::format()
- 7.3 plugins/FrxDrupal.inc \FrxDrupal::format()
- 7.4 plugins/FrxDrupal.inc \FrxDrupal::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/
FrxDrupal.inc, line 70 - Provides data blocks for native drupal connections using the default drupal connections.
Class
- FrxDrupal
- @file Provides data blocks for native drupal connections using the default drupal connections.
Code
public function format($value, $key, $data) {
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 .= "'" . db_escape_string($v) . "'";
}
$value = $val;
}
}
else {
$value = trim($value);
$value = "'" . db_escape_string($value) . "'";
}
}
return $value;
}