简体   繁体   中英

$wpdb->get_results shows and empty array

I am trying to get some data form wordpress db and it somehow gives me back an empty array. When I am trying this query below I receive the whole details and it is working perfectly.

$query = $wpdb->prepare("SELECT * FROM $wpdb->usermeta");

But when trying this query below it gives me back an empty array like this: array(0){}

$user_data = get_userdata($current_user_id); // get current user data by id 
$user_url = $user_data->user_url; // get current user url
$user_url = substr($user_url, 6);

global $wpdb;
$query = $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE meta_value = %s", $user_url);
echo $query;

$results = $wpdb->get_results($query);
var_dump($results);

Please help me, I am trying to figure it out without any success...

user_url is a column in the wp_users table. It's not in the metadata.table.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM