public static function format(array $values)
{
$string = "";
foreach ($values as $key => $value) {
if ($key = self::stripNonSQLCharacters($key)) {
if ($value === null) {
$value = 'NULL';
} else {
if (is_int($value) || is_float($value)) {
// Preserve content of $value as is
} else {
if (is_bool($value)) {
$value = $value ? 'TRUE' : 'FALSE';
} elseif (is_array($value)) {
$value = '[' . implode(',', $value) . ']';
} else {
$value = '"' . addslashes($value) . '"';
}
}
}
$string .= " {$key} = {$value},";
}
}
return substr($string, 0, strlen($string) - 1);
}