Blogger Information
Blog 62
fans 3
comment 1
visits 29674
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
thinkphp 数据库 高级查询与请求测试
kiraseo_wwwkiraercom
Original
322 people have browsed it

thinkphp 数据库 高级查询与请求测试

thinkphp 高级查询写法

方法

  1. public function index(){
  2. //查询数据表总条数
  3. $re = Db::name('user')->count();
  4. echo '总共有'.$re.'数据';
  5. // 查询name字段的重复次数
  6. $re1 = Db::name('user')->fieldRaw('name,Count(name) as count')->group('name')->fetchSql(false)->select()->toArray();
  7. echo '过滤掉重复数据<br/>';
  8. foreach($re1 as $v){
  9. extract($v);
  10. echo $name.'重复'.$count.'次数<br/>';
  11. }
  12. }

输出结果

thinkphp客户端请求测试

get方法请求测试

  1. public function get_q(){
  2. $data = Request::param();
  3. print_r($data);
  4. }

输出结果

post方法请求测试

  1. public function get_post(){
  2. $data = Request::param();
  3. print_r($data);
  4. }

输出结果

Correcting teacher:PHPzPHPz

Correction status:qualified

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