Thinkphp 5.0 获取最后执行的SQL

 1   
 2          $q=new Question();
 3             $q->save(['qcount'=>$qs->qcount+1],['id'=>input('qid')]);
 4            ///////=========================================
 5         var_dump((new Question())->db()->getLastSql());   //=
 6             ///=================================================
 7             //die;
 8             $stu = new Student();
 9             $res = $stu->save([
10                 'qid' => input('qid'),
11                 'tid' => input('tid'),
12                 'lock' => 1
13             ], [
14                 'uname' => Session::get('uname')
15             ]);
16         用的就是
(new Question())->db()->getLastSql();

 

执行操作的是哪个数据表, 就用哪个数据模型

你可能感兴趣的:(Thinkphp 5.0 获取最后执行的SQL)