How to select and use multiple key/value rows in tables like ‘wp_options’ (PHP/MySQL)

It’s hard to switch out of “normal” MySQL mode and start working with data stored in key/value format. The ‘wp_options’ table is an example of storing data in this key/value¬†format. I was working on a cron job that required data from the ‘wp_options’ table. This is how I got where I needed to go:

So if you want to retrieve specific key/value data in one pass with MySQL and then assign the results to PHP variables, this method might work for you:

2 thoughts on “How to select and use multiple key/value rows in tables like ‘wp_options’ (PHP/MySQL)

    1. Agreed. Switch out these depreciated mysql extensions for whatever you are using.
      The query used for selecting data from a key/value table is solid though.

Leave a Reply

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