Blogger Information
Blog 94
fans 0
comment 0
visits 92711
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
【ThinkPHP】数据库事务和ThinkPHP请求
可乐随笔
Original
1614 people have browsed it

1. 数据库事务

// ! 9. 数据库事务        // * startTrans 事务开启        // ? 事务要求 数据库引擎是: InnoDB, 不支持MyISAM        // Db::startTrans();        // $data = [        //     'ooid' => '1234567890',        //     'uid' => 1,        //     'price' => 111,        //     'phone' => '18809511111',        //     'name' => '欧阳克',        //     'sj_price' => 111,        // ];        // $oid = Db::table('order')->insertGetID($data);        // // * 事务提交: commit ; 事务回滚: rollback        // if (empty($oid)) {        //     Db::rollback();        // }        // // 订单联动提交,失败进行事物回滚        // $details = Db::table('order_details')->insert([        //     'oid' => $oid,        //     'shop_id' => 1,        //     'price' => 111        // ]);        // $details = 0;        // if (empty($details)) {        //     Db::rollback();        // }        // Db::commit();

2. ThinkPHP 请求

        // ! 请求        // print_r($_GET);        // * 使用门面类获取get        // print_r(Request::get());        // ? get方法,传参数: 第1个是数据,第2个是数据类型:d整数/s字符串/b布尔/a数组/f浮点        // print_r(Request::get('id/d'));        // print_r(Request::get('name'));        print_r(Request::param());        print_r(Request::post());        // ! 获取请求方法        // * 应用场景1: 屏蔽无关请求        // if(Request::method() == 'GET')        // {        //     echo "请用POST请求!";        //     exit;        // }        // * 参数方法        // print_r(Request::scheme());        // echo '://';        // print_r(Request::host());        // print_r(Request::url());        // print_r(Request::controller());        // print_r(Request::action());
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