Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin

tommcfarlin/00-query-stub.php Secret

Last active Sep 4, 2018
Embed
What would you like to do?
[WordPress] Database Queries in WordPress
<?php
global $wpdb;
$results = $wpdb->get_results(
$wpdb->prepare(
"
",
$userId
),
ARRAY_A
);
if (empty($results)) {
return;
}
$results = array_map($results, 'column_name');
<?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