Combine two meta queries into one #4901

This commit is contained in:
Mike Jolley 2014-02-25 13:33:55 +00:00
parent 3d4f16a7a4
commit 9a52c5dd43
1 changed files with 3 additions and 10 deletions

View File

@ -566,15 +566,6 @@ class WC_Admin_CPT_Shop_Order extends WC_Admin_CPT {
// Search orders
$post_ids = array_unique( array_merge(
$wpdb->get_col(
$wpdb->prepare( "
SELECT post_id
FROM {$wpdb->postmeta}
WHERE meta_key IN ('" . implode( "','", $search_fields ) . "') AND meta_value LIKE '%%%s%%'
",
esc_attr( $_GET['s'] )
)
),
$wpdb->get_col(
$wpdb->prepare( "
SELECT p1.post_id
@ -584,8 +575,10 @@ class WC_Admin_CPT_Shop_Order extends WC_Admin_CPT {
( p1.meta_key = '_billing_first_name' AND p2.meta_key = '_billing_last_name' AND CONCAT(p1.meta_value, ' ', p2.meta_value) LIKE '%%%s%%' )
OR
( p1.meta_key = '_shipping_first_name' AND p2.meta_key = '_shipping_last_name' AND CONCAT(p1.meta_value, ' ', p2.meta_value) LIKE '%%%s%%' )
OR
( p1.meta_key IN ('" . implode( "','", $search_fields ) . "') AND p1.meta_value LIKE '%%%s%%' )
",
esc_attr( $_GET['s'] ), esc_attr( $_GET['s'] )
esc_attr( $_GET['s'] ), esc_attr( $_GET['s'] ), esc_attr( $_GET['s'] )
)
),
$wpdb->get_col(