Blogger Information
Blog 37
fans 0
comment 0
visits 14296
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
thinkphp 高级查询和请求类型
秋闲独醉
Original
504 people have browsed it

1、Thinkphp 数据库 高级查询练习

  1. //高级查询
  2. //快捷查询
  3. $res = Db::name('order')
  4. // ->where('order_id|order_sn','=',201804171129599877)
  5. ->where('order_amount&total_amount','<',200)
  6. ->select();
  7. //批量字段查询
  8. $res = Db::name('order')
  9. ->where([
  10. ['uid','=',1],
  11. ['order_id','>',10]
  12. ])
  13. ->select();
  14. //whereColumn比较两个字段
  15. $res = Db::name('order')
  16. ->whereColumn('confirm_time','>','add_time')
  17. ->select();
  18. //动态查询
  19. $res = Db::name('order')
  20. ->whereConsignee('上海滩')
  21. ->find();
  22. $res = Db::name('order')
  23. ->getByConsignee('上海滩');
  24. $res = Db::name('order')
  25. ->getFieldByConsignee('上海滩','order_sn');
  26. var_dump($res);

2、thinkphp 请求练习

  1. public function demo()
  2. {
  3. //post请求方式
  4. if(!Request::isPost()){
  5. return '请求的类型不是post';
  6. }
  7. $post = Request::post('id/d');
  8. $name = Request::post('name/s');
  9. echo $post;
  10. echo '------------';
  11. echo $name;
  12. echo '------------';
  13. //get 请求方式
  14. // $get =Request::get('name');
  15. // return $get;
  16. //获取header
  17. $info = Request::header();
  18. echo $info['accept'];
  19. echo '------------';
  20. echo $info['accept-encoding'];
  21. echo '------------';
  22. echo $info['user-agent'];
  23. }
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