gpt4 book ai didi

php - 复杂的元查询不起作用

转载 作者:行者123 更新时间:2023-11-30 22:40:06 24 4
gpt4 key购买 nike

我有一个非常复杂的元查询,分为两部分。每个部分单独工作都很好,但是当我将两个部分与 or 进行比较时,它应该显示两个结果的组合,但它没有显示任何内容。

第一个片段

array(
'relation' => 'AND',
array(
'relation' => 'AND',
array(
'key' => 'range1_min',
'value' => floatval($_GET['m']),
'type' => 'DECIMAL',
'compare' => '<='
),
array(
'key' => 'range1_max',
'value' => floatval($_GET['m']),
'type' => 'DECIMAL',
'compare' => '>='
)
),
array(
'relation' => 'AND',
array(
'key' => 'range1_min',
'value' => floatval($_GET['n']),
'type' => 'DECIMAL',
'compare' => '<='
),
array(
'key' => 'range1_max',
'value' => floatval($_GET['n']),
'type' => 'DECIMAL',
'compare' => '>='
)
)
);

第二个片段

array(
'relation' => 'AND',
array(
'relation' => 'AND',
array(
'key' => 'range2_min',
'value' => floatval($_GET['m']),
'type' => 'DECIMAL',
'compare' => '<='
),
array(
'key' => 'range2_max',
'value' => floatval($_GET['m']),
'type' => 'DECIMAL',
'compare' => '>='
)
),
array(
'relation' => 'AND',
array(
'key' => 'range2_min',
'value' => floatval($_GET['n']),
'type' => 'DECIMAL',
'compare' => '<='
),
array(
'key' => 'range2_max',
'value' => floatval($_GET['n']),
'type' => 'DECIMAL',
'compare' => '>='
)
)
);

它们各自都工作正常,但当我将它们与“OR”条件放在一起时,它们就无法工作。

完整代码片段

array(
'relation' => 'OR',
array(
'relation' => 'AND',
array(
'relation' => 'AND',
array(
'key' => 'range1_min',
'value' => floatval($_GET['m']),
'type' => 'DECIMAL',
'compare' => '<='
),
array(
'key' => 'range1_max',
'value' => floatval($_GET['m']),
'type' => 'DECIMAL',
'compare' => '>='
)
),
array(
'relation' => 'AND',
array(
'key' => 'range1_min',
'value' => floatval($_GET['n']),
'type' => 'DECIMAL',
'compare' => '<='
),
array(
'key' => 'range1_max',
'value' => floatval($_GET['n']),
'type' => 'DECIMAL',
'compare' => '>='
)
)
) ,
array(
'relation' => 'AND',
array(
'relation' => 'AND',
array(
'key' => 'range2_min',
'value' => floatval($_GET['m']),
'type' => 'DECIMAL',
'compare' => '<='
),
array(
'key' => 'range2_max',
'value' => floatval($_GET['m']),
'type' => 'DECIMAL',
'compare' => '>='
)
),
array(
'relation' => 'AND',
array(
'key' => 'range2_min',
'value' => floatval($_GET['n']),
'type' => 'DECIMAL',
'compare' => '<='
),
array(
'key' => 'range2_max',
'value' => floatval($_GET['n']),
'type' => 'DECIMAL',
'compare' => '>='
)
)
)
);

如有任何帮助,我们将不胜感激。

最佳答案

当我生成 wordpress 的 sql 查询并在 phpmyadmin 上运行它时,它生成错误并说我已经超出了默认连接设置,这意味着在我的查询中我有太多连接。

我已通过在 wordpress 查询之前手动放置此 sql 查询来解决此错误。

global $wpdb
$wpdb->query("SET SQL_BIG_SELECTS = 1");

关于php - 复杂的元查询不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31367800/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com