I have looked inside WordPress database.

Example:

In wp_options table, option_name column, active_plugins row, its option_value is

a:7:{i:0;s:27:"clean-html/cleanup-html.php";i:1;s:59:"force-regenerate-thumbnails/force-regenerate-thumbnails.php";i:2;s:36:"google-sitemap-generator/sitemap.php";i:3;s:39:"thumbnail-upscale/thumbnail-upscale.php";i:4;s:24:"wordpress-seo/wp-seo.php";i:5;s:27:"wp-super-cache/wp-cache.php";i:6;s:19:"wptouch/wptouch.php";}

I guess that a is array, 7 is array’s length, i is integer, s is string, etc.

What is this data type called? How to generate (encode) to store and how to read (decode) to use?

I think this storing solution perfectly fits to what I’m doing in my current project.

1 Answer
1

I have looked inside WordPress database.

Never do that unless you need to have an external utility to be able to read data from the DB. For wordpress development always use the proper API for what you need, there was a lot of time invested into making the APIs efficient and there is no need to reinvent the wheel.

In options case just use the options API to set and retrieve the option values. And let them handle how to best write the data to the DB.

Leave a Reply

Your email address will not be published. Required fields are marked *