Re Enable Transactions after using trans_off() |
To disable database transactions at run-time you can call
PHP Code: $this->db->trans_off(); Maybe I am missing something but I don't see any way to reverse this call to allow transaction processing. The abstract class DB_driver defines trans_off() with this code. PHP Code: public function trans_off() The property $trans_enabled is used throughout the class to allow (or not) class methods to proceed. For instance PHP Code: public function trans_start($test_mode = FALSE) The "issue", if there is one, is that the documentation at Enabling Transactions implies that calling $this->db->trans_start(); will re-start transaction processing after a call to $this->db->trans_off(); But that is not the case as the code snippet above clearly illustrates.
"disable" doesn't just mean "stop" or "end", it means you're not allowed to do it.
Ya, I get that. But the example might leave people to believe that the not allowed status is reversed by calling trans_start().
That makes no sense, the whole point of trans_off() is to make trans_start() do nothing.
I get that too. I have no argument with the implementation. But look at the documentation link I provided. The example does suggest that after a call to trans_off() you can resume using transactions by calling trans_start(). There's more than one post on SO where their problem was a misunderstanding trans_off().
The Enabling Transactions section begins with
Quote:Transactions are enabled automatically the moment you use $this->db->trans_start(). If you would like to disable transactions you can do so using $this->db->trans_off(): which is followed immediately by this example code. PHP Code: $this->db->trans_off(); And you don't think that this example suggests, implies or otherwise demonstrates that transactions will be resumed after the call to trans_off()? That has to be because of your intimate knowledge of the source code. Without that knowledge and within the context of "Enabling Transactions" I don't see how the example can be interpreted in any way other than a demonstration of trans_start() as being the opposite of trans_off(). If the point of the example is to explain that the call $this->db->query('AN SQL QUERY...'); will not be handled as a transaction then that needs to be explicitly stated. The fact that Quote:"disable" doesn't just mean "stop" or "end", it means you're not allowed to do it.needs to be explained as does the fact that neither trans_start() or trans_begin() will reverse that state. (10-23-2016, 08:20 AM)dave friend Wrote: The Enabling Transactions section begins with I argree that this sentence is confusing: Quote:Transactions are enabled automatically the moment you use $this->db->trans_start(). If you would like to disable transactions you can do so using $this->db->trans_off(): It is wrong in at least 2 ways. But the example itself is in no way incorrect, and you did only talk about the example up until now. There's nothing wrong or misleading in the example itself.
(10-24-2016, 12:23 AM)Narf Wrote: https://github.com/bcit-ci/CodeIgniter/c...e0c7c1f8ef Thank you. |
Welcome Guest, Not a member yet? Register Sign In |