我想从post meta表中获取元键为“project\\u id”的所有数据。我写了一个查询,它应该在Theory中工作,但我无法看到我得到了什么,并且将这个查询注入我的插件不会生成任何东西。请查看此查询,并帮助我了解其是否正确,结果的格式是什么,如何回传以查看我得到的结果:
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 );
}
编辑:var\\u转储得到以下结果:
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"
}
}
如何访问每个对象中的3个字符串?