Blogger Information
Blog 47
fans 0
comment 0
visits 21097
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
TP数据库操作和请求
P粉036614676
Original
392 people have browsed it

1.数据库操作

1.1 in , not in

  1. $res = Db::table('course')->where('Cno','not in','3,4,5,6')->select()->toArray();
  2. print_r($res);

1.2 like, not like

  1. % _
  2. $res = Db::table('course')->where('Cname','like','数%')->select()->toArray();
  3. print_r($res);

1.3 and or

  1. $res = Db::table('course')->where('Cname','数学')->where('Cpno',7)->select()->toArray();
  2. // print_r($res);
  3. // $res = Db::table('course')->where('Cname','数学')->whereOr('Cname','操作系统')->select()->toArray();
  4. // print_r($res);

1.4其他

  1. //聚合操作
  2. // $res = Db::table('course')->sum('Cno');
  3. // echo $res;
  4. //排序 ASC,DESC
  5. $res = Db::table('course')->order('Cno','DESC')->field('Cno')->select()->toArray();
  6. print_r($res);
  7. //group 和 having
  8. //page 和 limit

2.TP请求

  1. /**
  2. * d:整数
  3. * s:字符串
  4. * a:数组
  5. * f:浮点数
  6. * b:布尔值
  7. *
  8. * $_GET $_POST和 Request::get() Request::post()一样
  9. */
  10. print_r(Request::get('id/b'));
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