当前位置: 首页 > news >正文

网站设计建设趋势seo网站seo

网站设计建设趋势,seo网站seo,个人网站网站建设,广东上海专业网站建设公司哪家好教程地址#xff1a;Hyperf 一、安装 1.1 hyperf框架 composer require hyperf/db-connection 1.2 其他框架 composer require hyperf/database 二、配置 配置项类型默认值备注driverstring无数据库引擎hoststring无数据库地址databasestring无数据库默认 DBusernamest…教程地址Hyperf 一、安装 1.1 hyperf框架 composer require hyperf/db-connection 1.2 其他框架 composer require hyperf/database 二、配置 配置项类型默认值备注driverstring无数据库引擎hoststring无数据库地址databasestring无数据库默认 DBusernamestring无数据库用户名passwordstringnull数据库密码charsetstringutf8数据库编码collationstringutf8_unicode_ci数据库编码prefixstring数据库模型前缀timezonestringnull数据库时区pool.min_connectionsint1连接池内最少连接数pool.max_connectionsint10连接池内最大连接数pool.connect_timeoutfloat10.0连接等待超时时间pool.wait_timeoutfloat3.0超时时间pool.heartbeatint-1心跳pool.max_idle_timefloat60.0最大闲置时间optionsarrayPDO 配置 options相关pdo文档PHP: PDO - Manual 三、多库配置、读写分离、原生查询、sql输出 由于hyperf/database 衍生于 illuminate/database 。 illuminate/database多库配置和读写分离参考illuminate/database 使用 四-CSDN博客  原生查询和sql输出参考illuminate/database 使用 五-CSDN博客 。 3.1 原生查询-事务 3.1.1 自动管理数据库事务 根据文档描述如果事务的闭包 Closure 中出现一个异常事务将会回滚。如果事务闭包 Closure 执行成功事务将自动提交。 确实比手动方便但是还得查下报错怎么处理。 根据之前文章应该明白Illuminate\Database中调用顺序即从Illuminate\Database\Capsule\Manager最后会调用到Illuminate\Database\Connectionl。Connectionl中调用Concerns\ManagesTransactions类。transaction()方法在ManagesTransactions类中被调用。 源码如下 trait ManagesTransactions {/*** Execute a Closure within a transaction.** param \Closure $callback* param int $attempts* return mixed** throws \Throwable*/public function transaction(Closure $callback, $attempts 1){for ($currentAttempt 1; $currentAttempt $attempts; $currentAttempt) {$this-beginTransaction();// Well simply execute the given callback within a try / catch block and if we// catch any exception we can rollback this transaction so that none of this// gets actually persisted to a database or stored in a permanent fashion.try {$callbackResult $callback($this);}// If we catch an exception well rollback this transaction and try again if we// are not out of attempts. If we are out of attempts we will just throw the// exception back out and let the developer handle an uncaught exceptions.catch (Throwable $e) {$this-handleTransactionException($e, $currentAttempt, $attempts);continue;}try {if ($this-transactions 1) {$this-getPdo()-commit();}$this-transactions max(0, $this-transactions - 1);if ($this-transactions 0) {optional($this-transactionsManager)-commit($this-getName());}} catch (Throwable $e) {$this-handleCommitTransactionException($e, $currentAttempt, $attempts);continue;}$this-fireConnectionEvent(committed);return $callbackResult;}}/*** Handle an exception encountered when running a transacted statement.** param \Throwable $e* param int $currentAttempt* param int $maxAttempts* return void** throws \Throwable*/protected function handleTransactionException(Throwable $e, $currentAttempt, $maxAttempts){// On a deadlock, MySQL rolls back the entire transaction so we cant just// retry the query. We have to throw this exception all the way out and// let the developer handle it in another way. We will decrement too.if ($this-causedByConcurrencyError($e) $this-transactions 1) {$this-transactions--;optional($this-transactionsManager)-rollback($this-getName(), $this-transactions);throw $e;}// If there was an exception we will rollback this transaction and then we// can check if we have exceeded the maximum attempt count for this and// if we havent we will return and try this query again in our loop.$this-rollBack();if ($this-causedByConcurrencyError($e) $currentAttempt $maxAttempts) {return;}throw $e;} /*** Handle an exception encountered when committing a transaction.** param \Throwable $e* param int $currentAttempt* param int $maxAttempts* return void** throws \Throwable*/protected function handleCommitTransactionException(Throwable $e, $currentAttempt, $maxAttempts){$this-transactions max(0, $this-transactions - 1);if ($this-causedByConcurrencyError($e) $currentAttempt $maxAttempts) {return;}if ($this-causedByLostConnection($e)) {$this-transactions 0;}throw $e;}…… } 如源码所示闭包执行错误执行handleTransactionException()方法处理回滚并抛出异常。 $this-transactions--大概是处理事务嵌套相关代码。 提交异常执行handleCommitTransactionException()方法嵌套事务大概会继续执行最后抛出异常。 测试代码 function test4() {Capsule::transaction(function () {Capsule::table(userinfo)-where([id 1])-update([votes 1]);}); } test4(); 运行结果 Fatal error: Uncaught PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column votes in field list in D:\workspace\php\wj_test\illuminate_database\vendor\illuminate\database\Connection.php on line 712Illuminate\Database\QueryException: SQLSTATE[42S22]: Column not found: 1054 Unknown column votes in field list (SQL: update userinfo set votes 1 where (id 1)) in D:\workspace\php\wj_test\illuminate_database\vendor\illuminate\database\Connection.php on line 712Call Stack:0.0009 411368 1. {main}() D:\workspace\php\wj_test\illuminate_database\test.php:00.0208 1925160 2. test4() D:\workspace\php\wj_test\illuminate_database\test.php:1190.0208 1925480 3. Illuminate\Database\Capsule\Manager::transaction(class Closure) D:\workspace\php\wj_test\illuminate_database\test.php:1170.0208 1925856 4. Illuminate\Database\Capsule\Manager::__callStatic(string(11), array(1)) D:\workspace\php\wj_test\illuminate_database\test.php:1170.0269 2634512 5. Illuminate\Database\MySqlConnection-transaction(class Closure, ???) D:\workspace\php\wj_test\illuminate_database\vendor\illuminate\database\Capsule\Manager.php:2000.0705 3895296 6. Illuminate\Database\MySqlConnection-handleTransactionException(class Illuminate\Database\QueryException, long, long) D:\workspace\php\wj_test\illuminate_database\vendor\illuminate\database\Concerns\ManagesTransactions.php:37 此时update执行Illuminate\Database\Connection::update(),update调用Connection::run()执行,run()通过Connection::runQueryCallback()执行,产生PDO异常再将PDO异常传递给\Illuminate\Database\QueryException异常。 使用throw 会直接输出异常。 PDOExceptionPHP: PDOException - Manual 3.1.2 手动管理数据库事务 function test5() {Capsule::beginTransaction();try {Capsule::table(userinfo)-where([id 1])-update([votes 1]);Capsule::commit();} catch (\Throwable $th) {var_dump($th-getMessage());Capsule::rollBack();} } test5(); 和之前是同样的道理代码最后执行都是Connectionl类Connectionl::beginTransaction()、Connectionl::commit()、Connectionl::rollback()都是Connectionl中调用的ManagesTransactions类中的方法。 例子中Capsule类相当于官网的DB类。 四、构造器 参考 illuminate/database 使用 一-CSDN博客 Hyperf 自己写的博客有涉及一些运行原理官网的例子比较多。
http://www.zqtcl.cn/news/981171/

相关文章:

  • 具有品牌的网站建设霞浦建设局网站
  • 推荐个网站免费的wordpress force ssl
  • app网站搭建做英文网站的心得
  • 东莞企业网站制作推广运营多样化的网站建设公司
  • 深圳做网站那里好提交网址给百度
  • 泰州企业建站系统中企动力科技做什么的
  • 唐山公司网站建设 中企动力唐山宽带动态ip如何做网站访问
  • 个人商城网站怎么做电商网站及企业微信订烟
  • 温州市网站优化广告平面设计教程
  • 南通制作网站的有哪些公司吗sae 部署wordpress
  • 友情链接对网站的影响wordpress admin init
  • 渭南网站开发做网红用哪个网站
  • 湖北建设网站wordpress 翻页电子书
  • 网站设计命名规范厦门建站比较好的公司
  • 用vs2010做网站登入前端培训费用大概多少郑州
  • 网站建设后的效果评估杭州网站制作公司
  • 3网站建设公司影楼修图用什么软件
  • 手机网站的内容模块多用户商城开源左
  • 库尔勒网站建站宝盒合作
  • 五河网站建设哪家好wordpress获取文章作者
  • 怎么修改网站内容wordpress ajax接口
  • 绵阳市城乡建设和规划局网站重庆网站建设公司有哪些
  • 宿迁网站建设公司排名展厅设计企业
  • 做家具定制的设计网站开阿里巴巴网站建设流程
  • 站长统计软件广州免费核酸在哪里做
  • 做soho一定要做网站吗在百度网站备案查询上显示未备案是什么意思
  • 移动公司营销网站设计html旅游网站模板
  • 专业生产车间设计图纸网站ui设计师证
  • 如何建网站教程视频10种网络营销方法
  • 网站内链优化的角度wordpress缓存插件破解版