WP-Query-Builder icon indicating copy to clipboard operation
WP-Query-Builder copied to clipboard

Allow to get results as array instead objects

Open moiseh opened this issue 5 years ago • 0 comments

Hello, Thanks for the nice library.

Would be great if it's possible to define the query result types when call get() function and maybe another functions that return a list of rows.

Now it's returning array of stdClass objects, but sometimes it's easy to work with array of arrays. For example when using WP_List_Table WordPress class it's expect arrays by default.

This is the line that i'm having the issue: https://github.com/stephenharris/WP-Query-Builder/blob/master/src/Query.php#L296

Doing for example this code will fetch the arrays: $results = $this->db->get_results($sql, ARRAY_A);

I'm trying to extend the class Query and get() method but because it have some private attributes i need basically to rewrite the entire class.

Thanks

moiseh avatar Sep 23 '20 15:09 moiseh