Created
October 29, 2008 03:42
-
-
Save kovyrin/20615 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql> CREATE FUNCTION `xml_escape_with_br`( tagvalue VARCHAR(2000)) RETURNS varchar(2000) DETERMINISTIC BEGIN IF (tagvalue IS NULL) THEN RETURN null; END IF; RETURN REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( tagvalue,'&','&'), '<','<'), '>','>'), '"','"'), '\'','''), '\n', '<br/>'); END$$ | |
Query OK, 0 rows affected (0.00 sec) | |
mysql> DELIMITER ; | |
mysql> select xml_escape_with_br("<h1>hello, world!</h1>\n<p>We say: 'Alexey & Tikhon rock!'"); | |
+-----------------------------------------------------------------------------------------------+ | |
| xml_escape_with_br("<h1>hello, world!</h1>\n<p>We say: 'Alexey & Tikhon rock!'") | | |
+-----------------------------------------------------------------------------------------------+ | |
| <h1>hello, world!</h1><br/><p>We say: 'Alexey & Tikhon rock!' | | |
+-----------------------------------------------------------------------------------------------+ | |
1 row in set (0.04 sec) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment