Correction status:unqualified
Teacher's comments:有这个作业吗? 如果要写, 请写完整
数据库查询过程感觉和thinkphp很像
我这里就基于老师的代码扩展一下count方法好了
echo Db::table('staff')->where("sex = 1")->count();
public function count(){
$sql = 'SELECT '
. ' count(*) as a'
. ' FROM '
. $this->table
. $this->where;
$stmt = $this->pdo->prepare($sql);
$stmt->execute();
$data = $stmt->fetch(\PDO::FETCH_ASSOC);
return $data["a"];
}