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[0], second object is $result[1] 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[15].


You receive an array with the database column names as key.


You get an array with incrementing IDs as key.