From a8bc96228ead8daebeec423f4f341a1f5092e340 Mon Sep 17 00:00:00 2001 From: Damien Regad Date: Sat, 19 Jul 2025 18:48:52 +0200 Subject: Execute PRAGMA to retrieve PK after getting table info --- drivers/adodb-sqlite3.inc.php | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) (limited to 'drivers/adodb-sqlite3.inc.php') 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; } -- cgit v1.3