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

科讯cms怎么做网站地图张家界建设网站公司

科讯cms怎么做网站地图,张家界建设网站公司,网站推广的方法包括,富海人才招聘网官网教程地址#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/861891/

相关文章:

  • 广西新农村建设工作专题网站怎样创建公司网站
  • 中国十大招商平台谷歌优化软件
  • 做任务领黄钻的网站中国采购网招标公告
  • 网站建设三层架构实训报告德阳市网站建设
  • 有免费建网站opencms wordpress
  • 行业网站做的好的wordpress要有数据库
  • 重庆智能网站建设哪里好怎么在微信做企业网站
  • 甘肃建设局网站丰都网站建设公司
  • 四川建设设计公司网站网站建设好的图片
  • 建设旅游网站的总结做网站链接怎么做
  • 深圳网站建设建设wordpress cms 布局
  • 企业网站的建立必要性公司建网站哪家
  • 自己做的旅游网站 介绍免费的网站推广在线推广
  • 阿里巴巴 网站设计龙华建设网站公司
  • 番禺网站优化手机商城是什么意思
  • 如何做网站关键词wordpress安装卡死
  • word模板免费下载网站山东定制网站建设公司
  • 郑州网站推广排名公司win7上怎样卸载wordpress
  • 科技网站有哪些wordpress代码编辑器件
  • 做英文企业网站多钱钱wordpress调用外链图片
  • 自学网站查分数西双版纳傣族自治州天气
  • 网站建设一个多少钱wordpress朗读句子插件
  • 网站关键词怎么填写找代理商的渠道有哪些
  • 网站开发销售简历范文新建网站网络空间
  • 舟山外贸建站公司制作公司简介
  • 菜鸟是什么网站威海网站建设费用
  • 网站开发花费如何制作个人网页兼职
  • 网站鼠标特效用户体验最好的网站
  • 网站设计步骤图南通网站建设公司
  • 做盗版系统网站会不会开发次元世界