Blogger Information
Blog 12
fans 0
comment 1
visits 5845
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
8.1【模仿THINKPHP框架】
小陈先生的博客
Original
717 people have browsed it

数据库查询过程感觉和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"];
}

Correction status:unqualified

Teacher's comments:有这个作业吗? 如果要写, 请写完整
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post