Why is the automatic transaction option in CakePHP is called "atomic"?

Paulo Alexandre Chaves Pinto

I do not understand the meaning of the word "atomic". For example:

$conn = $this->ArticlesTable->connection();
$articles->save($entity, ['atomic' => false]); // <-- here
$conn->commit();

Should it not be be "autocommit" instead?

Dave

You're actually turning on/off "atomic" transactions, not "automatic" transactions.

"Atomic" is the correct term:

An atomic transaction is an indivisible and irreducible series of database operations such that either all occur, or nothing occurs. A guarantee of atomicity prevents updates to the database occurring only partially, which can cause greater problems than rejecting the whole series outright.

-Wikipedia: Atomicity

The key there is "...such that either ALL occur, or NOTHING occurs."

When atomic is false (off), and you run a save that requires more than one query, it will run each individually and could be successful on some, but not others.

When atomic is true (on), and you run a save that requires more than one query, it will process them as a single transaction, and either complete all successfully or fail all completely. No partial saves/updates.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related