WP_QUERY命中最大联接数...否则,我如何构建使用自定义域的搜索函数?

时间:2014-06-26 作者:paper_robots

我正在尝试搜索一个自定义帖子类型的“属性”,同时我也在使用多个(5-30)meta\\u查询搜索自定义字段。问题是Wordpress或MySQL抛出了一个错误,说我达到了可以使用的JOIN语句数量的限制。

错误:[SELECT将检查超过MAX\\U JOIN\\U SIZE的行;检查您的WHERE并使用SET SQL\\U BIG\\U SELECTS=1或SET MAX\\U JOIN\\U SIZE=#如果选择正确]

因为我使用的是WP\\u Query,所以甚至可以设置这些选项吗?我还有别的办法吗?

以下是我的查询$参数的示例:

以下是我要传递给WP\\U查询的$参数:

 Array
(
[numberposts] => -1
[post_type] => properties
[status] => publish
[tax_query] => Array
    (
        [relation] => AND
        [0] => Array
            (
                [taxonomy] => markets
                [field] => id
                [terms] => Array
                    (
                        [0] => 27
                        [1] => 157
                    )

            )

    )

[meta_query] => Array
    (
        [relation] => AND
        [0] => Array
            (
                [key] => sleeps
                [value] => 3
                [type] => NUMERIC
                [compare] => >=
            )

        [1] => Array
            (
                [key] => minimum_rate_0_rate
                [value] => Array
                    (
                        [0] => 999
                        [1] => 2750
                    )

                [type] => NUMERIC
                [compare] => BETWEEN
            )

        [2] => Array
            (
                [key] => management
                [value] => Array
                    (
                        [0] => Professionally Managed
                        [1] => Privately Owned
                    )

                [type] => CHAR
                [compare] => LIKE
            )

        [3] => Array
            (
                [key] => property_type
                [value] => Array
                    (
                        [0] => Home
                        [1] => Condo
                    )

                [type] => CHAR
                [compare] => LIKE
            )

        [4] => Array
            (
                [key] => number_of_bedrooms
                [value] => Array
                    (
                        [0] => 1
                        [1] => 15
                    )

                [type] => NUMERIC
                [compare] => BETWEEN
            )

        [5] => Array
            (
                [key] => total_number_of_baths
                [value] => Array
                    (
                        [0] => 1
                        [1] => 10
                    )

                [type] => NUMERIC
                [compare] => BETWEEN
            )

        [6] => Array
            (
                [key] => pet_policy
                [value] => cat dog
                [type] => CHAR
                [compare] => LIKE
            )

        [7] => Array
            (
                [key] => pools_hot_tubs_and_saunas
                [value] => Array
                    (
                        [0] => Hot Tub
                    )

                [type] => CHAR
                [compare] => LIKE
            )

        [8] => Array
            (
                [key] => appliances_and_furniture
                [value] => Washer
                [type] => CHAR
                [compare] => LIKE
            )

        [9] => Array
            (
                [key] => phone_and_internet
                [value] => Internet
                [type] => CHAR
                [compare] => LIKE
            )

    )
()

1 个回复
SO网友:paper_robots

这似乎起到了作用,在我的WP\\U查询之前运行它:

$wpdb->query(\'SET OPTION SQL_BIG_SELECTS = 1\');

结束