简体   繁体   English

在没有mysqli的情况下处理MySQL事务

[英]Handling MySQL transactions without mysqli

I'm working on a university project at the moment and they've informed me that they won't support mysqli in their hosting environment. 目前,我正在一个大学项目上,他们已经告诉我他们在托管环境中不支持mysqli

While this seems a backwards decision to me, it's what I'm dealing with. 尽管这对我来说是一个倒退的决定,但这是我要处理的。 Is there a way to handle transactions in MySQL using the old mysql library? 有没有办法使用旧的mysql库处理MySQL中的事务?

We have a volatile process involving student data that really needs transaction handling. 我们的流程不稳定,涉及学生数据,而这些数据确实需要事务处理。 The process was written by students years ago and is naturally prone to errors. 该过程是由学生几年前编写的,并且很容易出错。 All of it was written with mysql functions until I converted them to mysqli . 所有这些都是使用mysql函数编写的,直到将它们转换为mysqli为止。 We don't have time or budget to refactor the whole thing, so I just need a way to get transactions working again. 我们没有时间或预算来重构整个事情,所以我只需要一种使事务重新运行的方法。 Thanks! 谢谢!

you do not want to go back to the old mysql as it is being taken out of PHP for a reason. 您不希望返回到旧的mysql因为出于某种原因它mysql PHP中删除。

Look into PDO : http://php.net/manual/en/book.pdo.php 查看PDOhttp : //php.net/manual/zh/book.pdo.php

And you will soon find yourself completely falling in love with this one. 而且您很快就会发现自己完全爱上了这个。 It exceeds mysql and mysqli by far, and your university will be happy to see this coming in 到目前为止,它已经超过了mysqlmysqli ,您的大学很高兴看到它的到来

Transactions in mysql are handled by means of simple SQL commands like START TRANSACTION and such. mysql中的事务是通过简单的SQL命令(如START TRANSACTION等)处理的。 You are allowed to issue these commands from client using whatever API you like. 您可以使用所需的任何API从客户端发出这些命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM