求某一列数据和
table.contents
表views
列数据之和,本身typecho并不存在views
列,这里只是举个例子
$db = \Typecho\Db::get();
echo $db->fetchObject($db->select(['SUM(views)' => 'Count'])->from('table.contents')
->where('type = ?', 'post'))->Count;
统计行数
事例为根据cid
统计文章数量
$db = \Typecho\Db::get();
return $db->fetchObject($db->select(['COUNT(cid)' => 'num'])
->from('table.contents')
->where('table.contents.type = ?', 'post'))->num;