我的问题是,我正在尝试返回以下内容。
If
user_login=$name_input AND
referrer=25 AND
qualified=0
return results
OR if
passup=26 AND
user_login=$name_input
return results.
此时,如果任何数组为真,它将返回结果。和不起作用?
$name_search = array(
\'search_columns\' => array( \'user_login\' ),
\'search\' => \'*\'.esc_attr( $name_input ).\'*\',
\'meta_query\' => array(
\'relation\' => \'OR\',
array(
\'relation\' => \'AND\',
array(
\'key\' => \'user_login\',
\'value\' => $name_input,
\'compare\' => \'LIKE\'
),
array(
\'key\' => \'referrer\',
\'value\' => \'25\',
\'compare\' => \'=\'
),
array(
\'key\' => \'qualified\',
\'value\' => \'0\',
\'compare\' => \'=\'
),
),
array(
\'relation\' => \'AND\',
array(
\'key\' => \'passup\',
\'value\' => \'26\',
\'compare\' => \'=\'
),
array(
\'key\' => \'user_login\',
\'value\' => $name_input,
\'compare\' => \'LIKE\'
),
),
),
);
$user_query = new WP_User_Query( $args );
这是SQL:
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) INNER JOIN wp_postmeta AS mt1 ON ( wp_posts.ID = mt1.post_id ) INNER JOIN wp_postmeta AS mt2 ON ( wp_posts.ID = mt2.post_id ) INNER JOIN wp_postmeta AS mt3 ON ( wp_posts.ID = mt3.post_id ) INNER JOIN wp_postmeta AS mt4 ON ( wp_posts.ID = mt4.post_id ) WHERE 1=1 AND wp_posts.ID NOT IN (756,1278,1369,1474,1560,1627,1679,1737) AND (
(
( wp_postmeta.meta_key = \'user_login\' AND CAST(wp_postmeta.meta_value AS CHAR) LIKE \'%bob%\' )
AND
( mt1.meta_key = \'referrer\' AND CAST(mt1.meta_value AS CHAR) = \'25\' )
AND
( mt2.meta_key = \'qualified\' AND CAST(mt2.meta_value AS CHAR) = \'0\' )
)
OR
(
( mt3.meta_key = \'passup\' AND CAST(mt3.meta_value AS CHAR) = \'26\' )
AND
( mt4.meta_key = \'user_login\' AND CAST(mt4.meta_value AS CHAR) LIKE \'%bob%\' )
)
) AND wp_posts.post_type = \'post\' AND (wp_posts.post_status = \'publish\' OR wp_posts.post_status = \'op_preview\' OR wp_posts.post_author = 24 AND wp_posts.post_status = \'private\') GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 10