Blogger Information
Blog 50
fans 0
comment 0
visits 31416
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
模型、请求
手机用户1580651468
Original
960 people have browsed it

模型、请求

一、模型

  1. 需要先引入,use
  2. C可以通过请求,获取外面的数据,然后给到model里,model在处理数据,返回数据。最后c返回数据给前端
  3. $OykOrder = new OykOrder();
  4. $data = [
  5. 'ooid' => '123456',
  6. 'uid' => 1,
  7. 'price' => 111,
  8. 'phone' => 18811112222,
  9. 'name' => 'XXX',
  10. 'sj_price' => 111,
  11. 'address' => '围栏上午刚'
  12. ];
  13. $getOrder = $OykOrder->getOrder(2);
  14. print_r($getOrder);

一、请求

1.请求

  1. $_GET$_POST
  2. print_r($_GET);
  3. print_r($_GET['id']);
  4. 用门面类获取get
  5. print_r(Request::get());
  6. 用门面类获取所有请求
  7. print_r(Request::param());
  8. 用门面类获取post
  9. print_r(Request::post());
  10. 传参数,代表直接获取这个数据
  11. 参数强制 接收的数据类型
  12. d 整数、s字符串,b 布尔,a 数组,f浮点
  13. print_r(Request::get('id/b'));
  14. 引入类:带facade路径的,是门面类,不带的话,是普通类
  15. use think\facade\Db;
  16. use think\facade\Request;

2.请求方法

  1. if(Request::method() == 'GET'){
  2. echo '请用post请求';
  3. exit;
  4. } print_r(Request::isPost());

3.参数方法

  1. host 方法是打印域名
  2. print_r(Request::scheme());
  3. echo '://';
  4. print_r(Request::host());
  5. print_r(Request::url());
  6. print_r(Request::baseUrl());
  7. 数据表是 下滑线命令法。 对应modelmodel是驼峰命名法。
  8. oyk_order 对应 OykOrder
  9. oyk_order_details OykOrderDetails
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