what's the output of this query?
-
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 ); }
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘what's the output of this query?’ is closed to new replies.