我想选择一些具有相同term\\u组的标记,我在phpadmin中对其进行了测试,查询得到了正确的结果,但一旦添加了$wpdb flavor,它将返回一个空数组。有什么建议吗?
$primary_tag_id = // a function to return term_group, result is 3, comfirmed
$terms = $wpdb->get_col( $wpdb->prepare(
"SELECT name
FROM $wpdb->wp_terms
WHERE term_group = %d
ORDER BY name ASC", $primary_tag_id
));
最合适的回答,由SO网友:Stephen Harris 整理而成
试试这个,它对我有用:
global $wpdb;
$terms = $wpdb->get_col( $wpdb->prepare(
"SELECT name
FROM {$wpdb->terms}
WHERE term_group = %d
ORDER BY name ASC", primary_tag_id
));
你想要的是
$wpdb->terms
不
$wpdb->wp_terms