开发者

wordpress 3.2.1 database query

开发者 https://www.devze.com 2023-03-30 02:21 出处:网络
i am trying to make a simpl开发者_StackOverflow社区e selection in a wordpress table (created by a plugin). the table is named reduceri , and has the following columns: id, post, category.

i am trying to make a simpl开发者_StackOverflow社区e selection in a wordpress table (created by a plugin). the table is named reduceri , and has the following columns: id, post, category.

so, i am trying to take all the category values, when the post is equal to the current post id.

the way i am doing the query is:

$the_query = "
SELECT $wpdb->reduceri.category 
FROM $wpdb->reduceri
WHERE $wpdb->reduceri.post = ".$post_id."    
";

$my_reduceri = $wpdb->get_results($the_query);

but when i var_dump the $my_reduceri all i get is an empty array: array(0) { } even though there should actually be some results... any idea where i am wrong (in the query)?

thank you


Did you declared global $wpdb; before using this query?

0

精彩评论

暂无评论...
验证码 换一张
取 消