summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnoop Naik <anoopnaik2016@gmail.com>2019-03-06 12:33:51 +0530
committerDamien Regad <dregad@mantisbt.org>2020-01-04 18:20:20 +0100
commit0e510ff21d0013c95ec38036763039de42ed71c0 (patch)
treef6ea6f103ad6fcf05e55f3f5a017ca61a7c56d45
parente727e29b5e74abd5015446744e99ce026492d922 (diff)
downloadadodb-0e510ff21d0013c95ec38036763039de42ed71c0.tar.gz
adodb-0e510ff21d0013c95ec38036763039de42ed71c0.tar.bz2
adodb-0e510ff21d0013c95ec38036763039de42ed71c0.zip
mysql: genId() not returning next sequence value
There are numerous threads regarding intermittent problems with mysqli_insert_id(). This is an attempt to work around the problem by retrieving the last insert id from the sequence if mysqli_insert_id() does not return it. Fixes #493 Signed-off-by: Damien Regad <dregad@mantisbt.org> Original commit modified as follows - removed error suppression - replaced sprintf call by string contatenation - coding guidelines - rewrote commit message
-rw-r--r--drivers/adodb-mysqli.inc.php5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/adodb-mysqli.inc.php b/drivers/adodb-mysqli.inc.php
index b041c54e..c0950fdf 100644
--- a/drivers/adodb-mysqli.inc.php
+++ b/drivers/adodb-mysqli.inc.php
@@ -342,6 +342,11 @@ class ADODB_mysqli extends ADOConnection {
if ($rs) {
$this->genID = mysqli_insert_id($this->_connectionID);
+ if ($this->genID == 0) {
+ $getnext = "select LAST_INSERT_ID() from " . $seqname;
+ $rs = $this->execute($getnext);
+ $this->genID = (int)$rs->fields[0];
+ }
$rs->Close();
} else
$this->genID = 0;