gpt4 book ai didi

php - PDO 事务代码警告与 mysqli

转载 作者:行者123 更新时间:2023-11-29 06:59:20 24 4
gpt4 key购买 nike

所以我的问题是我应该使用 PDO 还是 mysqli。我担心使用 PDO,因为来自 php PDO page 的以下警告.

Warning Beware: Some MySQL table types (storage engines) do not support transactions. When writing transactional database code using a table type that does not support transactions, MySQL will pretend that a transaction was initiated successfully. In addition, any DDL queries issued will implicitly commit any pending transactions.

  • 这会在未来造成什么样的问题?

  • 如果我只使用 mysqli 会更好吗? (不确定是否有同样的问题)

最佳答案

我认为这个警告是因为所有类型的mysql存储引擎都不支持事务。不支持事务的引擎会立即自动提交数据。因此,请检查引擎列表及其工作差异。

mysql> SHOW ENGINES;
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
| InnoDB | YES | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO |
| CSV | YES | CSV storage engine | NO | NO | NO |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
| FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL |
| ARCHIVE | YES | Archive storage engine | NO | NO | NO |
| MyISAM | DEFAULT | Default engine as of MySQL 3.23 with great performance | NO | NO | NO |
+------------+---------+----------------------------------------------------------------+--------------+------+------------+

关于php - PDO 事务代码警告与 mysqli,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44149897/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com