Result Types of $wpdb->get_results()
If you query the WordPress database using $wpdb->get_results(), you can specify the desired return type. You can select between four options.
This one is the default. You get an array of objects of type stdClass. The array uses a numeric identifiert, that starts with 0. First object is $result, second object is $result and so on.
OBJECT_K is pretty similar to OBJECT, the difference is, that the array key matches the primary ID of the desired object. So, if your result has the ID 15, you can access it by $result.
You receive an array with the database column names as key.
You get an array with incrementing IDs as key.
- Query Custom Data in WordPress
- Get ID of Data Inserted by $wpdb->insert
- Manage MySQL Databases and Users from the Command Line
- Configure WordPress Backend Search to Search Titles Only
- Get Post Meta
- Tutorial: Ubuntu 18.04 LAMP Setup for WordPress
- Force Easy Digital Downloads Updater to Check for Updates