CodeIgniter Framework update transaction (transaction) bug and workaround, CodeIgniter framework
Because the CI transaction judged that the condition of the rollback was that the statement was successful, while the update operation, even if the affected number of bars was executed by the 0,sql statement, the result is still 1 because it succeeds, only the number of bars affected is 0.
Here's how to solve this problem:
For a transaction that executes many statements at a time
Just under the update operation, depending on whether the number of bars affected is zero or not, it is assumed that the second statement is an update operation.
Copy CodeThe code is as follows:
Manual mode with CodeIgniter transactions
$this->db->trans_strict (FALSE);
$this->db->trans_begin ();
$this->db->query (' SELECT ... ');//select operation without special handling
$this->db->query (' INSERT ... ')//insert error will be codeigniter automatic processing
$this->db->query (' UPDATE ... ');
if (! $this->db->affacted_rows ()) {//UPDATE above fails to rollback
$this->db->trans_rollback ();
@todo Exception Handling Section
Exit ();//need to stop or jump out to avoid the following SQL code to continue execution!
}
$this->db->query (' DELETE ... ');
if (! $this->db->affacted_rows ()) {//DELETE above fails to rollback
$this->db->trans_rollback ();
@todo Exception Handling Section
Exit ();//need to stop or jump out to avoid the following SQL code to continue execution!
}
$this->db->query (' SELECT ... ');//select operation without special handling
$this->db->query (' INSERT ... ')//insert error will be codeigniter automatic processing
if ($this->db->trans_status () = = = TRUE) {
$this->db->trans_commit ();
} else {
$this->db->trans_rollback ();
@todo Exception Handling Section
}
If there are not many statements executed at one time, you can determine the rollback by making a final decision.
If there is no update operation in the statement, the automatic transaction is available.
CodeIgniter Framework supports simultaneous access to many people
Concurrency has a major relationship to the server architecture, but the optimization of the program also has a lot to do with, such as how the cache is applied. Of course it doesn't have much to do with frames.
For PHP CodeIgniter Framework
Yesterday just read the CodeIgniter Handbook, in CodeIgniter URLs This chapter has the description method:
This is done by adding rules to the. htaccess file, as follows
Rewriteengine on
Rewritecond $!^ (index\.php|images|robots\.txt)
Rewriterule ^ (. *) $/index.php/$1 [L]
http://www.bkjia.com/PHPjc/848801.html www.bkjia.com true http://www.bkjia.com/PHPjc/848801.html techarticle CodeIgniter Framework Update transaction (transaction) Bug and resolution, CodeIgniter framework because the CI transaction judgment error rollback condition is that the statement is executed successfully, while the update operation, ...