简体   繁体   中英

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.

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?

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 . 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.

Look into PDO : http://php.net/manual/en/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

Transactions in mysql are handled by means of simple SQL commands like START TRANSACTION and such. You are allowed to issue these commands from client using whatever API you like.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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