public static function quoted($value, $addQuotes = true)
    {
        if (is_null($value)) {
            $value = 'NULL';
        } else {
            $value = str_replace('\'', '\'\'', $value);
            if ($addQuotes) {
                $value = "'{$value}'";
            }
        }

        return $value;
    }