版本: v2.3.0
count
统计数据表中匹配的记录数。
count($table, $where)
table [string]
要查询的数据表名称。
where [array] (可选)
用于筛选待统计记录的 WHERE 条件。
count($table, $join, $column, $where)
table [string]
要查询的数据表名称。
join [array]
用于关联相关数据表的 JOIN 定义;如果不需要 JOIN,可省略此参数。
column [string]
要统计的列。
where [array] (可选)
用于筛选待统计记录的 WHERE 条件。
返回值
[int] 返回匹配的记录数。
此方法始终返回整数。
$count = $database->count("account", [
"gender" => "female"
]);
echo "共有 {$count} 位女性用户。";