By mistake, I changed input by textareas, and wyswyg updated all the values like
`http://google.com/?search=...` (url) to `<p>http://google.com/?search=..开发者_如何学C.</p>`
What correct mysql sentence can i use to fix this? PHP strip_tags()
won't work :(
Maybe something like this:
UPDATE table SET column = REPLACE(column, "<p>", "");
UPDATE table SET column = REPLACE(column, "</p>", "");
Untested and possibly harmful !
Here's the reference:
http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_replace
Something along these lines perhaps:
UPDATE tablename SET columnname = TRIM(LEADING '<p>' FROM TRIM(TRAILING '</p>' FROM columnname));
This might be faster:
UPDATE tablename SET columnname = TRIM(LEADING '<p>' FROM TRIM(TRAILING '</p>' FROM columnname)) WHERE columnname LIKE '<p>%</p>';
References:
TRIM (and other string functions)
LIKE (and other string comparison operators)
精彩评论