I want to get all the data with the meta key of "project_id" from post meta table. I wrote a query, it should work in thoery, but I have no way to see what I get, and inject this query to my plugin doesn't generate anything. Please take a look at this query, and help me understand if it is correct, what's the formate of the outcome, How can I echo it to see what I get:
function mp_all_ids( ){
global $bp, $wpdb, $post;
$query = <<<QUERY
SELECT project_id.post_id
FROM $wpdb->postmeta project_id
LEFT JOIN $wpdb->postmeta height
on height.post_id = project_id.post_id
and height.meta_key = 'height'
LEFT JOIN $wpdb->postmeta width
on width.post_id = project_id.post_id
and width.meta_key = 'width'
WHERE project_id.meta_key = 'project_id'
ORDER BY project_id.meta_value+(0) ASC
QUERY;
$data = $wpdb->get_results( $query );
return apply_filters( 'mp_ids', $data );
}
Edit: the var_dump gets the following result:
array(3) {
[0]=>
object(stdClass)#457 (1) {
["post_id"]=>
string(3) "385"
}
[1]=>
object(stdClass)#458 (1) {
["post_id"]=>
string(3) "451"
}
[2]=>
object(stdClass)#377 (1) {
["post_id"]=>
string(3) "453"
}
}
How can I access the 3 strings in each object?