summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUrban Müller2017-12-19 15:08:52 +0100
committerUrban Müller2017-12-19 15:08:52 +0100
commit87152ed9fb94135689b18967f00531d2a0d0ac1a (patch)
treea69c884c8d867fd21f755162474c021b395e338a
parentcab6d315fcd1d27f38ccc8c2ca680bc4071bb1f5 (diff)
downloaditools-87152ed9fb94135689b18967f00531d2a0d0ac1a.tar.gz
itools-87152ed9fb94135689b18967f00531d2a0d0ac1a.tar.bz2
itools-87152ed9fb94135689b18967f00531d2a0d0ac1a.zip
report mysql warnings
-rw-r--r--it_dbi.class14
1 files changed, 12 insertions, 2 deletions
diff --git a/it_dbi.class b/it_dbi.class
index 2c71ff5..e4c3e2c 100644
--- a/it_dbi.class
+++ b/it_dbi.class
@@ -48,6 +48,7 @@ class it_dbi
var $_convertfunc; # Array of name => convert function (currently intval and floatval) for this field's values
var $_link; # DB link identifier (private)
var $_dbid; # string identifying db connection. used for _state_purgeshared from outside
+ var $_affectedrows;# Affected rows (mysql_affected_rows() gets clobbered)
/**
@@ -530,6 +531,15 @@ function query($query, $p = array())
it_dbi::_state_purgeshared($dbid);
}
+ $this->_affectedrows = $this->_link->affected_rows; # get_warnings() clobbers this
+ if (($warning = $this->_link->get_warnings()))
+ {
+ do
+ $messages[] = $warning->message;
+ while ($warning->next());
+ it::error('title' => "Mysql warning: " . $messages[0], 'body' => join("\n", $messages) . "\n");
+ }
+
if ($writing && $this->_p['throttle_writes'])
usleep(1000000 * (gettimeofday(true) - $start) * $this->_p['throttle_writes']);
@@ -774,7 +784,7 @@ function update($tags = array(), $where = null)
if ($result = $this->query("UPDATE " . $this->_from($where, true) . " $set " . $this->_where($where)))
{
- $result = mysqli_affected_rows($this->_link);
+ $result = $this->_affectedrows;
if (array_key_exists($this->_p['keyfield'], $tags)) # Did we just update the key?
$this->_key = $tags[$this->_p['keyfield']];
@@ -808,7 +818,7 @@ function delete($query = null)
}
if ($query && $this->query("DELETE " . $this->_from($query) . " " . $this->_where($query)))
- $result = mysqli_affected_rows($this->_link);
+ $result = $this->_affectedrows;
return $result;
}