Is it possible to change post_text programmatically?

Discussion forum for MOD Writers regarding MOD Development.
Locked
zvunks
Registered User
Posts: 19
Joined: Mon Jul 08, 2013 6:58 pm

Is it possible to change post_text programmatically?

Post by zvunks » Mon Jul 08, 2013 7:14 pm

Hi,
i need to fech each post, parse for expressions and replace with other.
But now i see that post_text is BLOB and there is a post_checksum field and i think if i modify something to post_text content, there will be trouble.

Also i saw that is possible to convert binary blob field into text with CONVERT(column USING utf8), but after i parse and replace post_text with the new content, the checksum will be incorect.

Is it possible to do this changes?

Thank you.
(Excuse my bad english)

User avatar
EXreaction
Former Team Member
Posts: 5666
Joined: Sun Aug 21, 2005 9:31 pm
Location: Wisconsin, U.S.
Name: Nathan

Re: Is it possible to change post_text programmatically?

Post by EXreaction » Tue Jul 09, 2013 2:18 am

You don't need to do any conversions on the data. When you fetch the post_text from the database it will be a normal string.

The post_checksum should just be md5(post_text).

You'll probably want to fetch the data from the post table, and run the post text through generate_text_for_edit(), then modify the results of that. Before you update it in the database, run generate_text_for_storage() and use the result from that to update in the database. This will make sure that bbcodes are handled correctly.

zvunks
Registered User
Posts: 19
Joined: Mon Jul 08, 2013 6:58 pm

Re: Is it possible to change post_text programmatically?

Post by zvunks » Tue Jul 09, 2013 5:11 am

Thank you!
I'll give it a try.

Locked

Return to “[3.0.x] MOD Writers Discussion”