meta_query custom DB / any solution?

Support MB Custom Table meta_query custom DB / any solution?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #23392
    jw_blnjw_bln
    Participant

    reference: meta_query with MB Custom Tables

    I need to loop (ordered and field-selected) through a custom database with Oxygen page builder.
    So there is no other way as to use a meta_query!
    You are offering "MB Custom Table" but as far as I understood no way to order such a table with meta_query.

    The referenced post is dated Feb 2018.
    Your comment was:
    "I’m not sure about this, because the way WordPress build SQL queries from meta query object is very complicated. I’ll see if I can do something."

    Was there any change within the roughly 2 years?
    If no implementation was possible: Is there any workaround on how to implement the first SQL request in a meta_query?

    Query:

    $args = array(
            'post_type'   => 'square',
            'meta_key'    => 'sq_text_order',
            // not meta-value-num, as it is a text field
            'orderby' => 'meta_value',
            'order'   => 'ASC',
            'meta_query'  => array(
                array(
                    'key' =>   'sq_select_squarematrix',
                    'value' => 'Home',
                    'compare' =>   '=' 
                    )
                )
            )
    );
    

    or:
    post_type=square&meta_key=sq_text_order&orderby=meta_value&order=ASC&meta_query%5B0%5D%5Bkey%5D=sq_select_squarematrix&meta_query%5B0%5D%5Bvalue%5D=Home&meta_query%5B0%5D%5Bcompare%5D==

    #23393
    Long NguyenLong Nguyen
    Moderator

    Hi,

    The custom table is not associated with the table wp_posts as the wp_postmeta, see more in this documentation https://codex.wordpress.org/Database_Description.

    Using the custom table helps us to get the post ID base on the field value. We also note on this case https://docs.metabox.io/extensions/mb-custom-table/#query-posts-with-wp_query.

    At this time, the extension does not support to use meta_query with the custom table. I will discuss this with the developer team and inform you later if there are some ideas.

    #23396
    jw_blnjw_bln
    Participant

    Hi Long,
    thanks, I see.
    Is it OK to ask in two weeks again?
    Please let the ticket open for this period of time.

    And only to understand the intention of this extension (sorry if I am dumb or unaware):
    Using a separate DB makes a lot of sense, e.g. performance, maintainability, etc.
    But what is a typical use case if the retrieved data cannot be ordered or selected by using meta_query?
    Maybe I am missing something...
    I mean, of course, I can use other frameworks like React, Vue, etc. if I want to have complete control (by doing a lot of coding), but this is a completely different story...

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.