I feel like this should be possible.
I have a function within my class which pulls a single row from my custom table:
class Get_Data{
public static function get_data_single_db()
{
global $wpdb;
$user_table_name = $wpdb->prefix . 'custom_table';
$results = $wpdb->get_results(
"SELECT *
FROM $user_table_name
WHERE unique_id = '$unique_id';"
);
return $results;
}
The $results array contains 7 keys. At the moment, outside of the class I am using this to extract a single key value:
Get_Data::get_data_single_db()[0]->key;
This works, but out of curiosity, could something like this work better:
Get_Data::get_data_single_db($key)
and in the function:
public static function get_data_single_db($key)
.....
return $results->key
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745288531a4620713.html
评论列表(0条)