Wordpress mysql select all rows which contain serialised data

February 23, 2015   

Wordpress's ecosystem rather evilly stores settings for plugins and themes by PHP serialised arrays in it's MySQL backend. The following mysql snippets might be useful to you when debugging serialised data. It should return you all of the mysql rows with serialised data in them.

SELECT option_id, option_value FROM wp_options WHERE option_value LIKE '\%:\{\%';

Perhaps you could also expand on this to ignore rows which have empty serialised data sets.

SELECT option_id, option_value FROM wp_options WHERE option_value LIKE '\%:\{\%' and option_value NOT LIKE '\%:\{\}%';

blog comments powered by Disqus