summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorraspopov <raspopov@cherubicsoft.com>2025-03-10 18:41:53 +0300
committerDamien Regad <dregad@mantisbt.org>2025-03-22 01:11:28 +0100
commit1f41aa621848c52e7043a27df04c495b20f3ab55 (patch)
tree4b792fd377d8c774b209e2f5aff94f373dd0ad93 /drivers
parent56133c813c2fed3b44dcaaf8cd480d5d41cfdfc6 (diff)
downloadadodb-1f41aa621848c52e7043a27df04c495b20f3ab55.tar.gz
adodb-1f41aa621848c52e7043a27df04c495b20f3ab55.tar.bz2
adodb-1f41aa621848c52e7043a27df04c495b20f3ab55.zip
Fix SQLite error reporting
Without debug flag, the library returns '0' instead of error messages and correct SQLite error codes. Fixes #1061, PR #1062
Diffstat (limited to 'drivers')
-rw-r--r--drivers/adodb-sqlite3.inc.php20
1 files changed, 13 insertions, 7 deletions
diff --git a/drivers/adodb-sqlite3.inc.php b/drivers/adodb-sqlite3.inc.php
index 7623a3c8..7e5f5ffd 100644
--- a/drivers/adodb-sqlite3.inc.php
+++ b/drivers/adodb-sqlite3.inc.php
@@ -32,7 +32,6 @@ class ADODB_sqlite3 extends ADOConnection {
var $dataProvider = "sqlite";
var $replaceQuote = "''"; // string to use to replace quotes
var $concat_operator='||';
- var $_errorNo = 0;
var $hasLimit = true;
var $hasInsertID = true; /// supports autoincrement ID?
var $hasAffectedRows = true; /// supports affected rows for update/delete?
@@ -276,17 +275,20 @@ class ADODB_sqlite3 extends ADOConnection {
return $this->_connectionID->changes();
}
+ protected function lastError()
+ {
+ $this->_errorMsg = $this->_connectionID->lastErrorMsg();
+ $this->_errorCode = $this->_connectionID->lastErrorCode();
+ }
+
function ErrorMsg()
{
- if ($this->_logsql) {
- return $this->_errorMsg;
- }
- return ($this->_errorNo) ? $this->ErrorNo() : ''; //**tochange?
+ return $this->_errorMsg;
}
function ErrorNo()
{
- return $this->_connectionID->lastErrorCode(); //**tochange??
+ return $this->_errorCode;
}
function SQLDate($fmt, $col=false)
@@ -335,7 +337,7 @@ class ADODB_sqlite3 extends ADOConnection {
{
$rez = $this->_connectionID->query($sql);
if ($rez === false) {
- $this->_errorNo = $this->_connectionID->lastErrorCode();
+ $this->lastError();
}
// If no data was returned, we don't need to create a real recordset
elseif ($rez->numColumns() == 0) {
@@ -647,6 +649,10 @@ class ADODB_sqlite3 extends ADOConnection {
// Prepare the statement
$stmt = $this->_connectionID->prepare($sql);
+ if ($stmt === false) {
+ $this->lastError();
+ return false;
+ }
// Set the first bind value equal to value we want to update
if (!$stmt->bindValue(1, $val, SQLITE3_BLOB)) {