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.

Leave a Reply

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