note 115553 added to mysqli.autocommit
| From: | rusxakep | Date: | Thu, 14 Aug 2014 14:58:46 +0000 |
| Subject: | note 115553 added to mysqli.autocommit | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-200189@lists.php.net to get a copy of this message | ||
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;
}
?>
----
Server IP: 72.52.91.14
Probable Submitter: 195.210.159.57
----
Manual Page -- http://php.net/manual/en/mysqli.autocommit.php
Edit -- https://master.php.net/note/edit/115553
Del: integrated -- https://master.php.net/note/delete/115553/integrated
Del: useless -- https://master.php.net/note/delete/115553/useless
Del: bad code -- https://master.php.net/note/delete/115553/bad+code
Del: spam -- https://master.php.net/note/delete/115553/spam
Del: non-english -- https://master.php.net/note/delete/115553/non-english
Del: in docs -- https://master.php.net/note/delete/115553/in+docs
Del: other reasons-- https://master.php.net/note/delete/115553
Reject -- https://master.php.net/note/reject/115553
Search -- https://master.php.net/manage/user-notes.php