Watching:

Using transactions


show more Using transactions provides you with in-depth training on Developer. Taught by David Powers as part of the Accessing Databases with Object-Oriented PHP show less
please wait ...

Using transactions

Both PDO and MySQLi have support for transactions. A transaction, is a set of SQL queries that's executed as a single unit. Changes are committed to the database, only if each part of the transaction is successful. If an error occurs at any stage during the transaction, you can roll back each record, to its original value. This is particularly useful for operations such as financial transfers, where it's vital that all parts of the transaction succeed.

Another advantage, is that all parts of a transaction are grouped into a single execution unit that locks records to prevent them from being modified by another connection. If you're using MySQL or MariaDB as your database, data must be stored using the InnoDB engine on MySQL or XtraDB on MariaDB. Some commands can't be rolled back. This mainly affects SQL statements such as drop, alter and create.

That define the structure of tables and databases. You can't use transactions with MyISAM tables. Neither PDO nor MySQLi ,issue a warning if you try to do so. They simply ignore rollback commands. MyISAM, was the default storage engine, prior to MySQL 5.5. So you might need to convert your tables, if you want to use transactions. If you're not sure how to convert a table from MyISAM to NODB, check out chapter five of my course, Up and Running with phpMyAdmin here on lynda.com

Using transactions
Video duration: 1m 43s 3h 47m Intermediate

Viewers:

Using transactions provides you with in-depth training on Developer. Taught by David Powers as part of the Accessing Databases with Object-Oriented PHP

Subject:
Developer
Software:
PHP
Author:
please wait ...