From 59d4b9d393baa1e0e62ba67a7ecda9c1d4607a7a Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Thu, 16 May 2019 18:40:21 +0200 Subject: show full sql statement on readback errs --- it_dbi.class | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/it_dbi.class b/it_dbi.class index c995d55..3c414f0 100644 --- a/it_dbi.class +++ b/it_dbi.class @@ -450,7 +450,7 @@ function _where($params) /** * Internal: Output class name::error message and terminate execution. */ -function _fatal($text) +function _fatal($text, $body = null) { $text = get_class($this).'::'.$text; @@ -460,7 +460,7 @@ function _fatal($text) if ($this->_link && ($res = @mysqli_fetch_row(mysqli_query($this->_link, 'select database()')))) # dont create extra errs $text .= ", DB: " . $res[0]; - it::fatal($text . ", Server: " . $this->_p['server']); + it::fatal(['title' => $text . ", Server: " . $this->_p['server'], 'body' => $body]); /* NOT REACHED */ } @@ -761,11 +761,11 @@ function insert($tags = array(), $command = "INSERT") $set = $this->_set($tags, "insert"); - if ($result = $this->query("$command INTO {$this->_p['table']} " . $set)) + if ($result = $this->query($query = "$command INTO {$this->_p['table']} " . $set)) { $id = ($this->_p['autoincrement'] && !isset($tags[$this->_p['keyfield']])) ? mysqli_insert_id($this->_link) : $tags[$this->_p['keyfield']]; if ($this->_p['keyfield'] && !$this->read($id) && $this->_p['safety']) - $this->_fatal("insert(): can't read record back (key truncated?), id=\"$id\""); + $this->_fatal("insert(): can't read record back (key truncated?), id=\"$id\"", $query); $this->_touchedids[$this->_key] = true; } -- cgit v1.2.3