How is the data stored in the database?

I have years of experience with PHP and MySQL, but just starting to develop plugins for WordPress and need some help.

Currently, I am working on a plugin that will add extra functionality to another plugin. I need to read the data stored by the original plugin and manipulate it with my plugin. So far so good, but when I open phpMyAdmin the data stored in the Original plugin table looks like this: a:2:{i:0;a:11:{s:2:"id";s:1:"1";s:7:"item_id";s:1:"1";s:4:"name";s:9:"section 1";s:5:"limit";s:1:"1";s:5:"order";s:6:"random";s:10:"difficulty";s:4:"easy";s:9:"timestamp";s:19:"2012-05-21 12:29:44";s:9: ... Can someone tell me how to read this. How is this method for storing data called and are there guides on how to read this data with other plugins.

Read More

EDIT: After further studding the code here is what I understand
s:2:"id"; this means: string with 2 character -> “id”.
s:7:"item_id"; this means: string with 7 character -> “item_id”.

a:4:{} this means there will be 4 arguments between the curly brackets.

The only thing I could not figure out is that is the i:0;?

Am I right with the above assumptions?

Thanks,
Radi.

Related posts

Leave a Reply

1 comment

  1. This is a serialized array. PHP is able to read them as if they were regular arrays (or objects, in some cases) by using the serialize and unserialize functions (WordPress does this for you).

    All you need with WordPress to do is use get_option (or comparable WordPress function calls to retrieve data) and use the array/object as normal.

    I would recommend you avoid editing the data raw in the database, since can really mess things up (I know from experience 🙂 ).