帝国cms插件开发 帝国CMS统计SQL查询记录数函数gettotal()

帝国CMS教程

统计SQL查询记录数函数gettotal()

特点:相对于num更高效的统计查询函数。

$empire->gettotal("统计SQL语句");

说明

gettotal()和num()的区别是:gettotal()采用SQL本身的count(*)函数来统计,而num()是采用PHP本身的函数,gettotal()更高效一些。

gettotal()里的统计数一定要as total,如:“count(*) as total”。

使用范例

$num=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_news");

echo"新闻表共有 ".$num." 条新闻";