开发者

Need to add LF to thousands of MySQL MEDIUMTEXT fields

I need to add a \n or LF or ASCII(x'0A') or however you want to encode it to the end of several thousand MySQL MEDIUMTEXT fields. I tried

update wp_posts set post_content = concat(post_content,ASCII(x'0A'));

but nothing is modified in the field as far as I can see. I suspect this is a limitation of MEDIUMTEXT/LONGTEXT fields, but it would be nice if MySQL would throw an error instead of saying it did something and doing nothing.

If I can't do it with update/concat, what other options do I have? Does someone have a chunk of php code I can use to do it in a loop?

Thanks for any input! I'm trying to get my wordpress site to validate with W3C, and I need the newlines so wordpress 开发者_C百科does not add a <p> tag inappropriately. Strange, I know.


I don't know where my brain was. I was using HeidiSQL as the interface to MySQL, and wasn't seeing the change in the database. But it did change, which I saw once I refreshed the table data. Sorry for the false question!


Try:

update wp_posts set post_content = concat(post_content,'\n');

I tested with a mediumtext field here and worked..

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜