Skip to content

Allow to get results as array instead objects #5

@moiseh

Description

@moiseh

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions