众所周知MyISAM引擎不支持事务,但是我只是知道不支持事务,并未测试具体的表现是什么,测试代码如下:
try { //开启事务 Db::startTrans(); //(1).id为1的数据name字段修改为gao $isUpdate1 = Db::table('member')->where(['id' => 1])->update([ 'name' => 'gao1' ]); if (!$isUpdate1) { throw new Exception('更新第1条数据失败,事务已经回滚.'); } //(2).id为2的数据name字段修改为chen $isUpdate2 = Db::table('member')->where(['id' => 2])->update([ 'name' => 'chen' ]); if (!$isUpdate2) { throw new Exception('更新第2条数据失败,事务已经回滚.'); } // 提交事务 Db::commit(); } catch (Exception $exception) { //事务回滚 Db::rollback(); echo $exception->getMessage() . PHP_EOL; }
通过测试发现MyISAM直接忽视开启事务,提交事务,回滚事务,上面的代码相当于你没有写开启事务,提交事务,事务回滚的效果一样,只要有数据库操作一律直接执行。完全等同于下面的代码:
try { //(1).id为1的数据name字段修改为gao $isUpdate1 = Db::table('member')->where(['id' => 1])->update([ 'name' => 'gao1' ]); if (!$isUpdate1) { throw new Exception('更新第1条数据失败'); } //(2).id为2的数据name字段修改为chen $isUpdate2 = Db::table('member')->where(['id' => 2])->update([ 'name' => 'chen' ]); if (!$isUpdate2) { throw new Exception('更新第2条数据失败'); } } catch (Exception $exception) { echo $exception->getMessage() . PHP_EOL; }
首先下载wkhtmltox-0.12.4_linux-generic-amd64.tar.xz (不要下载RPM包,依赖太多,需要x-server支持),并解压,执行测试运行正常tar wkhtmltox-0.12.4_linux-generic-amd64.tar.xzcd...
ThinkPHP中有一个debug调试功能,能输出报错文件的信息,并能看到这个函数被哪些函数调用,从框架的启动开始记录,特别方便调试。于是研究了下它的底层给予了实现。<?php //--框架核心--Start //框架内置错误处理 function errDealWith($er...
php7.1引入了PHP异步信号处理函数pcntl_async_signals() 来处理阻塞问题。在php7之前信号处理方式有2种,第一种是基于ticks来每执行一行代码来触发执行信号监听,第二种是直接while(true){ //监听信号 }第一种方式如果某行的代码阻塞时间较长会影响...
【一】.基本用法首先看看官方对send方法的解释:Sets the return value of the yield expression and resumes the generato...
在调用微信code换openid的接口curl报错curl Received HTTP code 403 from proxy after CONNECT,错误码56。可以看到是curl的代理有问题。然后我自己电脑设置代理去访问curl请求的地址,的确也返回了403,说明代理不允许访问这个地址,联系...
(1).php.ini配置允许加载远程文件allow_url_fopen = On(2).创建本地文件invoke.php<?php require('https://blog.20230611.cn/test.txt');(3).创建远程文件https:/...