我正在使用wordpress平台,在生成mysql查询时,我想显示该查询的行数。示例如下所示。
$query = ("SELECT wp_posts.ID, wp_term_relationships.object_id
FROM wp_posts
LEFT JOIN wp_term_relationships ON wp_posts.ID = wp_term_relationships.object_id
WHERE post_date <= '$now'
AND term_taxonomy_id = '$catid'
AND post_date >= '$then'
AND post_status = 'publish'");
现在,当我将此查询生成到phpmyadmin时,它会提供以下输出 显示行0 - 5(总共6行,查询耗时0.0013秒)
我想显示总行数i-e 6 ... 那么我必须使用什么功能才能显示它?
答案 0 :(得分:0)
$query = ("SELECT count(*), wp_posts.ID, wp_term_relationships.object_id
FROM wp_posts
LEFT JOIN wp_term_relationships ON wp_posts.ID = wp_term_relationships.object_id
WHERE post_date <= '$now'
AND term_taxonomy_id = '$catid'
AND post_date >= '$then'
AND post_status = 'publish'");