summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Regad <dregad@mantisbt.org>2025-07-19 18:48:52 +0200
committerDamien Regad <dregad@mantisbt.org>2025-08-03 18:05:05 +0200
commita8bc96228ead8daebeec423f4f341a1f5092e340 (patch)
tree8e0a2c1d85396289f89ac4482f38ccb90b9389c1
parent90a11eb03178e1e9ebd233d497c477fd6a581648 (diff)
downloadadodb-a8bc96228ead8daebeec423f4f341a1f5092e340.tar.gz
adodb-a8bc96228ead8daebeec423f4f341a1f5092e340.tar.bz2
adodb-a8bc96228ead8daebeec423f4f341a1f5092e340.zip
Execute PRAGMA to retrieve PK after getting table info
-rw-r--r--drivers/adodb-sqlite3.inc.php32
1 files changed, 7 insertions, 25 deletions
diff --git a/drivers/adodb-sqlite3.inc.php b/drivers/adodb-sqlite3.inc.php
index 6fdf2ab8..ead8c168 100644
--- a/drivers/adodb-sqlite3.inc.php
+++ b/drivers/adodb-sqlite3.inc.php
@@ -439,17 +439,6 @@ class ADODB_sqlite3 extends ADOConnection {
}
$table = strtolower($table);
- $pragmaData = array();
-
- /*
- * If we want the primary key, we must extract
- * it from the table statement, and the pragma
- */
- if ($primary)
- {
- $sql = 'PRAGMA table_info(?)';
- $pragmaData = $this->getAll($sql, [$table]);
- }
// Exclude the empty entry for the primary index
$sql = "SELECT name,sql
@@ -487,21 +476,9 @@ class ADODB_sqlite3 extends ADOConnection {
$indexes[$row[0]]['columns'] = array_map('trim',explode(',',$indexExpression[1][0]));
}
- if (isset($savem)) {
- $this->SetFetchMode($savem);
- $ADODB_FETCH_MODE = $save;
- }
-
- /*
- * If we want primary, add it here
- */
+ // If we want the primary key, we must extract it from the pragma
if ($primary){
-
- /*
- * Check the previously retrieved pragma to search
- * with a closure
- */
-
+ $pragmaData = $this->getAll('PRAGMA table_info(?);', [$table]);
$pkIndexData = array('unique'=>1,'columns'=>array());
$pkCallBack = function ($value, $key) use (&$pkIndexData) {
@@ -526,6 +503,11 @@ class ADODB_sqlite3 extends ADOConnection {
$indexes['PRIMARY'] = $pkIndexData;
}
+ if (isset($savem)) {
+ $this->SetFetchMode($savem);
+ $ADODB_FETCH_MODE = $save;
+ }
+
return $indexes;
}