脚本宝典收集整理的这篇文章主要介绍了php – 无法获取要显示的查询结果,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
//var_dump Result: array(1) { [0]=> object(stdClass)#349 (1) { ["COUNT(DISTINCT wrITing.ID)"]=> string(1) “2″ } } //Code: $authors = $wpdb->get_results("SELECT COUNT(DISTINCT writing.ID) From writing LEFT JOIN stories on writing.SID = stories.SID LEFT JOIN wp_users ON writing.ID = wp_users.ID WHERE (stories.SID = $the_SID)" ); echo VAR_dump($authors); PRint "Total Authors:" .$authors[0]->writing.ID ."<p>";
>将索引存储为单独的变量,然后在打印时使用它.
$t = "COUNT(DISTINCT writing.ID)"; print "Total Authors:" .$authors[0]->$t . "<p>";
>在MySQL查询中使用别名.
SELECT COUNT(DISTINCT writing.ID) AS writingID From writing LEFT JOIN stories ON writing.SID = stories.SID LEFT JOIN wp_users ON writing.ID = wp_users.ID WHERE (stories.SID = $the_SID)
然后,
print "Total Authors:" .$authors[0]->writingID . "<p>";
以上是脚本宝典为你收集整理的php – 无法获取要显示的查询结果全部内容,希望文章能够帮你解决php – 无法获取要显示的查询结果所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。