XF 2.2 text vs blob?

Robert9

Well-known member
What is the reason that XF uses blobs instead of text?
Because i dont want to add millions of fields i put all data for my next add-on in one text_field xf_forum.xc_data;
it looks like:

Code:
{"use_thread_icon":1,"icon_list_size_x":49,"icon_list_size_y":49,"icon_top_size_x":248,"icon_top_size_y":248,"icon_where":1,"attach_icon":1}

When I need my values i can do it in templates with

$forum.xc_data.use_thread_icon

I can see what is happen in phpMyAdmin
I dont need to to any translation encoding, decoding, whatever.

But there must be a reason why xf uses blob instead of text?
 
Last edited:
If the field is text, all the data must be valid UTF8. Depending on MySQL server configuration this might be 3-byte or 4-byte UTF8.

If it is a blob type, MySQL will not care about the contents.

Basically, if you are encoding arbitrary json use a blob field. If you are encoding very limited json which will never have unicode text, emojis or user provided text, then it can be safe to use text.

Finally, you really should be aware of the length limits. text or blob is limited to 64k bytes, while longtext or longblob is vastly larger.
 
Thank you very much.
The field is used to save vars from admin forms, mostly integers and a path for default icon.
i use
xc_forum.xc_data
xc_thread.xc_data
xc_post.xc_data

to save every new table_field i can save, when no search/filter/index is needed.
 
Top Bottom