function formatValue($type, $format, $value)
{
switch ($type) {
case 'bool':
case 'boolean':
if ($value == 't') {
return 'TRUE';
} elseif ($value == 'f') {
return 'FALSE';
} elseif ($value == '') {
return 'NULL';
} else {
return $value;
}
break;
default:
// Checking variable fields is difficult as there might be a size
// attribute...
if (strpos($type, 'time') === 0) {
// Assume it's one of the time types...
if ($value == '') {
return "''";
} elseif (strcasecmp($value, 'CURRENT_TIMESTAMP') == 0 || strcasecmp($value, 'CURRENT_TIME') == 0 || strcasecmp($value, 'CURRENT_DATE') == 0 || strcasecmp($value, 'LOCALTIME') == 0 || strcasecmp($value, 'LOCALTIMESTAMP') == 0) {
return $value;
} elseif ($format == 'EXPRESSION') {
return $value;
} else {
$this->clean($value);
return "'{$value}'";
}
} else {
if ($format == 'VALUE') {
$this->clean($value);
return "'{$value}'";
}
return $value;
}
}
}