-
-
Save tommcfarlin/83522e41b58ba2ee8633282cb03e6a60 to your computer and use it in GitHub Desktop.
[WordPress] Database Queries in WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
global $wpdb; | |
$results = $wpdb->get_results( | |
$wpdb->prepare( | |
" | |
", | |
$userId | |
), | |
ARRAY_A | |
); | |
if (empty($results)) { | |
return; | |
} | |
$results = array_map($results, 'column_name'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
global $wpdb; | |
$results = $wpdb->get_results( | |
$wpdb->prepare( | |
" | |
SELECT | |
user_id, | |
meta_value | |
FROM $wpdb->usermeta | |
WHERE meta_key LIKE %s | |
AND user_id = %d | |
", | |
'%wc_authorize_net_cim_customer_profile_id%', | |
wp_get_current_user()->ID; | |
), | |
ARRAY_A | |
); | |
if (empty($results)) { | |
return []; | |
} | |
$results = array_map($results, 'meta_value'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment