This one returns an object

$mylink = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id = 10");

An associative array

$mylink = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id = 10", ARRAY_A);

A numerically indexed array

$mylink = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id = 10", ARRAY_N);

I really see no difference between them except for different ways of displaying data i.e. echo $mylink->link_id or echo $mylink['link_id'] - I'm comfortable using any of these.

Is this just a matter of personal preference or is there a technical story to it?

PS. If it's a duplicate please post a link the comments.

1 Answer 1


With everything moving towards OOP programming with classes and the use of objects increasing and favored above the use of arrays as such, I would definitely go with returning results as an object. This just makes everything easier for future use

But at the end of the day, you should always use what you are comfortable with within a set scope while keeping up with current and future developments.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.