note 115553 deleted from mysqli.autocommit by salathe
| From: | salathe@php.net | Date: | Fri, 22 Aug 2014 08:10:41 +0000 |
| Subject: | note 115553 deleted from mysqli.autocommit by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-200265@lists.php.net to get a copy of this message | ||
Note Submitter: rusxakep
----
Glen,
In persistent connection's, you should run autocommit (true) in shutdown function, otherwise,
you got lock's in "post" (not transactional) query's.
No commit and not rollback function's don't back autocommit value.
<?php
/**
* @return bool
*/
public function begin_transaction() {
if (!$this->link->autocommit(false)) return FALSE;
$this->t_in_progress = true;
register_shutdown_function([$this, "__shutdown_check"]);
$this->link->begin_transaction();
return TRUE;
}
/**
*
*/
public function __shutdown_check() {
if ($this->t_in_progress) {
$this->rollback();
}
if (!$this->link->autocommit(true)) return FALSE;
}
/**
* @return bool
*/
public function commit() {
if (!$this->link->commit()) return FALSE;
$this->t_in_progress = false;
return TRUE;
}
/**
* @return bool
*/
public function rollback() {
if (!$this->link->rollback()) return FALSE;
$this->t_in_progress = false;
return TRUE;
}
?>